TabM is an MLP-based tabular deep learning model that represents an ensemble of k
MLPs: the k submodels are trained in parallel on the same batches and share most of
their weights.
The network produces k predictions per observation; the learner averages the
predicted probabilities (classification) or the predicted values (regression)
over the k submodels, and its loss function trains all k submodels jointly.
Numerical features are used as-is, or – if the num_embeddings parameter is set –
embedded feature-wise first.
Categorical features are one-hot encoded.
Parameters
Parameters from LearnerTorch, as well as:
arch_type::character(1)
The architecture type, one of:"tabm"(default) – BatchEnsemble with the TabM initialization, i.e. all multiplicative adapters except the very first one are initialized with ones."tabm-mini"– all non-shared parameters are concentrated in a single elementwise affine transformation applied to the input.
k::integer(1)
The number of ensemble members. Default is32.n_blocks::integer(1)
The number of blocks of the MLP backbone. If unset,2is used whennum_embeddingsis set and3otherwise.d_block::integer(1)
The width of the MLP backbone. Default is512.dropout::numeric(1)
The dropout rate. Default is0.1.activation::character(1),nn_module_generatororfunction
The activation function of the MLP backbone. Either the name of an activation of thetorchpackage (e.g."relu","nn_relu"or"ReLU"), annn_module_generatorsuch asnn_relu, or a function returning annn_module. Default is"relu".start_scaling_init::character(1)
The initialization of the very first (non-shared) scaling, either"random-signs"or"normal". If unset,"normal"is used whennum_embeddingsis set and"random-signs"otherwise.
Parameters of the embeddings for the numerical features:
num_embeddings::character(1)
The type of the numerical feature embeddings, one of"none"(default),"linear_relu","periodic"or"piecewise_linear".d_embedding::integer(1)
The embedding size. If unset,32is used for"linear_relu",24for"periodic"and16for"piecewise_linear".n_frequencies::integer(1)"periodic"only: the number of frequencies per feature. Default is48.frequency_init_scale::numeric(1)"periodic"only: the initialization scale of the frequencies. This is an important hyperparameter. Default is0.01.lite::logical(1)"periodic"only: whether the outer linear layer is shared between all features. Default isFALSE.embedding_activation::logical(1)"periodic"and"piecewise_linear"only: whether a ReLU is applied at the end of the embedding. If unset,TRUEis used for"periodic"andFALSEfor"piecewise_linear".n_bins::integer(1)"piecewise_linear"only: the number of quantile bins, computed from the training data. Must be smaller than the number of training observations. Default is48.
Loss and Prediction
The network output has shape (batch, k, d_out).
At training time the learner therefore applies the configured loss to the k predictions
separately: the ensemble dimension is folded into the batch dimension and each target is
repeated k times. $loss itself is left untouched and stays whatever was configured.
For prediction, the per-submodel probabilities (softmax for multiclass, sigmoid for
binary) are averaged over the k submodels; for regression the outputs are averaged.
References
Gorishniy Y, Kotelnikov A, Babenko A (2025). “TabM: Advancing Tabular Deep Learning with Parameter-Efficient Ensembling.” In The Thirteenth International Conference on Learning Representations (ICLR). 2410.24210, https://openreview.net/forum?id=Sd4wYYOhmY.
Wen Y, Tran D, Ba J (2020). “BatchEnsemble: An Alternative Approach to Efficient Ensemble and Lifelong Learning.” In The Eighth International Conference on Learning Representations (ICLR). 2002.06715, https://openreview.net/forum?id=Sklf1yrYDr.
Super classes
mlr3::Learner -> LearnerTorch -> LearnerTorchTabM
Methods
Inherited methods
mlr3::Learner$base_learner()mlr3::Learner$configure()mlr3::Learner$encapsulate()mlr3::Learner$help()mlr3::Learner$predict()mlr3::Learner$predict_newdata()mlr3::Learner$reset()mlr3::Learner$selected_features()mlr3::Learner$train()LearnerTorch$dataset()LearnerTorch$format()LearnerTorch$marshal()LearnerTorch$print()LearnerTorch$unmarshal()
LearnerTorchTabM$new()
Creates a new instance of this R6 class.
Usage
LearnerTorchTabM$new(
task_type,
optimizer = NULL,
loss = NULL,
callbacks = list()
)Arguments
task_type(
character(1))
The task type, either"classif" or"regr".optimizer(
TorchOptimizer)
The optimizer to use for training. Per default, adam is used.loss(
TorchLoss)
The loss used to train the network. Per default, mse is used for regression and cross_entropy for classification.callbacks(
list()ofTorchCallbacks)
The callbacks. Must have unique ids.
Examples
# Define the Learner and set parameter values
learner = lrn("classif.tabm")
learner$param_set$set_values(
epochs = 1, batch_size = 16, device = "cpu",
k = 4, n_blocks = 2, d_block = 32
)
# Define a Task
task = tsk("iris")
# Create train and test set
ids = partition(task)
# Train the learner on the training ids
learner$train(task, row_ids = ids$train)
# Make predictions for the test rows
predictions = learner$predict(task, row_ids = ids$test)
# Score the predictions
predictions$score()
#> classif.ce
#> 0.6