Configurations
Core Configuration
pytorch_tabular.config.DataConfig
dataclass
Data configuration.
PARAMETER | DESCRIPTION |
---|---|
target |
A list of strings with the names of the target column(s). It is mandatory for all except SSL tasks.
TYPE:
|
continuous_cols |
Column names of the numeric fields. Defaults to []
TYPE:
|
categorical_cols |
Column names of the categorical fields to treat differently. Defaults to []
TYPE:
|
date_columns |
(Column names, Freq) tuples of the date fields. For eg. a field named introduction_date and with a monthly frequency should have an entry ('intro_date','M'}
TYPE:
|
encode_date_columns |
Whether or not to encode the derived variables from date
TYPE:
|
validation_split |
Percentage of Training rows to keep aside as validation. Used only if Validation Data is not given separately
TYPE:
|
continuous_feature_transform |
Whether or not to transform the features before
modelling. By default it is turned off.. Choices are: [
TYPE:
|
normalize_continuous_features |
Flag to normalize the input features(continuous)
TYPE:
|
quantile_noise |
NOT IMPLEMENTED. If specified fits QuantileTransformer on data with added gaussian noise with std = :quantile_noise: * data.std ; this will cause discrete values to be more separable. Please not that this transformation does NOT apply gaussian noise to the resulting data, the noise is only applied for QuantileTransformer
TYPE:
|
num_workers |
The number of workers used for data loading. For windows always set to 0
TYPE:
|
pin_memory |
Whether or not to pin memory for data loading.
TYPE:
|
handle_unknown_categories |
Whether or not to handle unknown or new values in categorical columns as unknown
TYPE:
|
handle_missing_values |
Whether or not to handle missing values in categorical columns as unknown
TYPE:
|
pytorch_tabular.config.ModelConfig
dataclass
Base Model configuration
PARAMETER | DESCRIPTION |
---|---|
task |
Specify whether the problem is regression or classification.
TYPE:
|
head |
The head to be used for the model. Should be one of the heads defined in
TYPE:
|
head_config |
The config as a dict which defines the head. If left empty, will be initialized as default linear head.
TYPE:
|
embedding_dims |
The dimensions of the embedding for each categorical column as a list of tuples (cardinality, embedding_dim). If left empty, will infer using the cardinality of the categorical column using the rule min(50, (x + 1) // 2)
TYPE:
|
embedding_dropout |
Dropout to be applied to the Categorical Embedding. Defaults to 0.0
TYPE:
|
batch_norm_continuous_input |
If True, we will normalize the continuous layer by passing it through a BatchNorm layer.
TYPE:
|
learning_rate |
The learning rate of the model. Defaults to 1e-3.
TYPE:
|
loss |
The loss function to be applied. By Default it is MSELoss for regression and CrossEntropyLoss for classification. Unless you are sure what you are doing, leave it at MSELoss or L1Loss for regression and CrossEntropyLoss for classification
TYPE:
|
metrics |
the list of metrics you need to track during training. The metrics
should be one of the functional metrics implemented in
TYPE:
|
metrics_prob_input |
Is a mandatory parameter for classification metrics defined in the config. This defines whether the input to the metric function is the probability or the class. Length should be same as the number of metrics. Defaults to None.
TYPE:
|
metrics_params |
The parameters to be passed to the metrics function.
TYPE:
|
target_range |
The range in which we should limit the output variable. Currently ignored for multi-target regression. Typically used for Regression problems. If left empty, will not apply any restrictions
TYPE:
|
seed |
The seed for reproducibility. Defaults to 42
TYPE:
|
pytorch_tabular.config.SSLModelConfig
dataclass
Base SSLModel Configuration
PARAMETER | DESCRIPTION |
---|---|
encoder_config |
The config of the encoder to be used for the model. Should be one of the model configs defined in PyTorch Tabular
TYPE:
|
decoder_config |
The config of decoder to be used for the model. Should be one of the model configs defined in PyTorch Tabular. Defaults to nn.Identity
TYPE:
|
embedding_dims |
The dimensions of the embedding for each categorical column as a list of tuples (cardinality, embedding_dim). If left empty, will infer using the cardinality of the categorical column using the rule min(50, (x + 1) // 2)
TYPE:
|
embedding_dropout |
Dropout to be applied to the Categorical Embedding. Defaults to 0.1
TYPE:
|
batch_norm_continuous_input |
If True, we will normalize the continuous layer by passing it through a BatchNorm layer. DEPRECATED - Use head and head_config instead
TYPE:
|
learning_rate |
The learning rate of the model. Defaults to 1e-3
TYPE:
|
seed |
The seed for reproducibility. Defaults to 42
TYPE:
|
pytorch_tabular.config.TrainerConfig
dataclass
Trainer configuration
PARAMETER | DESCRIPTION |
---|---|
batch_size |
Number of samples in each batch of training
TYPE:
|
data_aware_init_batch_size |
Number of samples in each batch of training for the data-aware initialization, when applicable. Defaults to 2000
TYPE:
|
fast_dev_run |
runs n if set to
TYPE:
|
max_epochs |
Maximum number of epochs to be run
TYPE:
|
min_epochs |
Force training for at least these many epochs. 1 by default
TYPE:
|
max_time |
Stop training after this amount of time has passed. Disabled by default (None)
TYPE:
|
gpus |
DEPRECATED: Number of gpus to train on (int). -1 uses all available GPUs. By default uses CPU (None)
TYPE:
|
accelerator |
The accelerator to use for training. Can be one of
'cpu','gpu','tpu','ipu', 'mps', 'auto'. Defaults to 'auto'.
Choices are: [
TYPE:
|
devices |
Number of devices to train on (int). -1 uses all available devices. By default uses all available devices (-1)
TYPE:
|
devices_list |
List of devices to train on (list). If specified, takes
precedence over
TYPE:
|
accumulate_grad_batches |
Accumulates grads every k batches or as set up in the dict. Trainer also calls optimizer.step() for the last indivisible step number.
TYPE:
|
auto_lr_find |
Runs a learning rate finder algorithm (see this paper) when calling trainer.tune(), to find optimal initial learning rate.
TYPE:
|
auto_select_gpus |
If enabled and
TYPE:
|
check_val_every_n_epoch |
Check val every n train epochs.
TYPE:
|
gradient_clip_val |
Gradient clipping value
TYPE:
|
overfit_batches |
Uses this much data of the training set. If nonzero, will use the same training set for validation and testing. If the training dataloaders have shuffle=True, Lightning will automatically disable it. Useful for quickly debugging or trying to overfit on purpose.
TYPE:
|
deterministic |
If true enables cudnn.deterministic. Might make your system slower, but ensures reproducibility.
TYPE:
|
profiler |
To profile individual steps during training and assist in identifying
bottlenecks. None, simple or advanced, pytorch. Choices are:
[
TYPE:
|
early_stopping |
The loss/metric that needed to be monitored for early stopping. If None, there will be no early stopping
TYPE:
|
early_stopping_min_delta |
The minimum delta in the loss/metric which qualifies as an improvement in early stopping
TYPE:
|
early_stopping_mode |
The direction in which the loss/metric should be optimized. Choices are:
[
TYPE:
|
early_stopping_patience |
The number of epochs to wait until there is no further improvements in loss/metric
TYPE:
|
early_stopping_kwargs |
Additional keyword arguments for the early stopping callback. See the documentation for the PyTorch Lightning EarlyStopping callback for more details.
TYPE:
|
checkpoints |
The loss/metric that needed to be monitored for checkpoints. If None, there will be no checkpoints
TYPE:
|
checkpoints_path |
The path where the saved models will be
TYPE:
|
checkpoints_every_n_epochs |
Number of training steps between checkpoints
TYPE:
|
checkpoints_name |
The name under which the models will be saved. If left blank,
first it will look for
TYPE:
|
checkpoints_mode |
The direction in which the loss/metric should be optimized
TYPE:
|
checkpoints_save_top_k |
The number of best models to save
TYPE:
|
checkpoints_kwargs |
Additional keyword arguments for the checkpoints callback. See the documentation for the PyTorch Lightning ModelCheckpoint callback for more details.
TYPE:
|
load_best |
Flag to load the best model saved during training
TYPE:
|
track_grad_norm |
Track and Log Gradient Norms in the logger. -1 by default means no tracking. 1 for the L1 norm, 2 for L2 norm, etc.
TYPE:
|
progress_bar |
Progress bar type. Can be one of:
TYPE:
|
precision |
Precision of the model. Can be one of:
TYPE:
|
seed |
Seed for random number generators. Defaults to 42
TYPE:
|
trainer_kwargs |
Additional kwargs to be passed to PyTorch Lightning Trainer. See https://pytorch-lightning.readthedocs.io/en/latest/api/pytorch_lightning.trainer.html#pytorch_lightning.trainer.Trainer
TYPE:
|
pytorch_tabular.config.ExperimentConfig
dataclass
Experiment configuration. Experiment Tracking with WandB and Tensorboard
PARAMETER | DESCRIPTION |
---|---|
project_name |
The name of the project under which all runs will be logged. For Tensorboard this defines the folder under which the logs will be saved and for W&B it defines the project name
TYPE:
|
run_name |
The name of the run; a specific identifier to recognize the run. If left blank, will be assigned a auto-generated name
TYPE:
|
exp_watch |
The level of logging required. Can be
TYPE:
|
log_target |
Determines where logging happens - Tensorboard or W&B. Choices are:
[
TYPE:
|
log_logits |
Turn this on to log the logits as a histogram in W&B
TYPE:
|
exp_log_freq |
step count between logging of gradients and parameters.
TYPE:
|
pytorch_tabular.config.OptimizerConfig
dataclass
Optimizer and Learning Rate Scheduler configuration.
PARAMETER | DESCRIPTION |
---|---|
optimizer |
Any of the standard optimizers from torch.optim.
TYPE:
|
optimizer_params |
The parameters for the optimizer. If left blank, will use default parameters.
TYPE:
|
lr_scheduler |
The name of the LearningRateScheduler to use, if any, from
torch.optim.lr_scheduler. If None, will not use any scheduler. Defaults to
TYPE:
|
lr_scheduler_params |
The parameters for the LearningRateScheduler. If left blank, will use default parameters.
TYPE:
|
lr_scheduler_monitor_metric |
Used with ReduceLROnPlateau, where the plateau is decided based on this metric
TYPE:
|
pytorch_tabular.config.ExperimentRunManager(exp_version_manager='.pt_tmp/exp_version_manager.yml')
The manages the versions of the experiments based on the name. It is a simple dictionary(yaml) based lookup. Primary purpose is to avoid overwriting of saved models while runing the training without changing the experiment name.
PARAMETER | DESCRIPTION |
---|---|
exp_version_manager |
The path of the yml file which acts as version control. Defaults to ".pt_tmp/exp_version_manager.yml".
TYPE:
|
Source code in src/pytorch_tabular/config/config.py
Head Configuration
In addition to these core classes, we also have config classes for heads
pytorch_tabular.models.common.heads.LinearHeadConfig
dataclass
A model class for Linear Head configuration; serves as a template and documentation. The models take a dictionary as input, but if there are keys which are not present in this model class, it'll throw an exception.
PARAMETER | DESCRIPTION |
---|---|
layers |
Hyphen-separated number of layers and units in the classification/regression head. eg. 32-64-32. Default is just a mapping from intput dimension to output dimension
TYPE:
|
activation |
The activation type in the classification head. The default activaion in PyTorch like ReLU, TanH, LeakyReLU, etc. https://pytorch.org/docs/stable/nn.html#non-linear-activations- weighted-sum-nonlinearity
TYPE:
|
dropout |
probability of an classification element to be zeroed.
TYPE:
|
use_batch_norm |
Flag to include a BatchNorm layer after each Linear Layer+DropOut
TYPE:
|
initialization |
Initialization scheme for the linear layers. Defaults to
TYPE:
|
pytorch_tabular.models.common.heads.MixtureDensityHeadConfig
dataclass
MixtureDensityHead configuration
PARAMETER | DESCRIPTION |
---|---|
num_gaussian |
Number of Gaussian Distributions in the mixture model. Defaults to 1
TYPE:
|
sigma_bias_flag |
Whether to have a bias term in the sigma layer. Defaults to False
TYPE:
|
mu_bias_init |
To initialize the bias parameter of the mu layer to predefined cluster centers. Should be a list with the same length as number of gaussians in the mixture model. It is highly recommended to set the parameter to combat mode collapse. Defaults to None
TYPE:
|
weight_regularization |
Whether to apply L1 or L2 Norm to the MDN layers. Defaults
to L2. Choices are: [
TYPE:
|
lambda_sigma |
The regularization constant for weight regularization of sigma layer. Defaults to 0.1
TYPE:
|
lambda_pi |
The regularization constant for weight regularization of pi layer. Defaults to 0.1
TYPE:
|
lambda_mu |
The regularization constant for weight regularization of mu layer. Defaults to 0
TYPE:
|
softmax_temperature |
The temperature to be used in the gumbel softmax of the mixing coefficients. Values less than one leads to sharper transition between the multiple components. Defaults to 1
TYPE:
|
n_samples |
Number of samples to draw from the posterior to get prediction. Defaults to 100
TYPE:
|
central_tendency |
Which measure to use to get the point prediction. Defaults to mean. Choices
are: [
TYPE:
|
speedup_training |
Turning on this parameter does away with sampling during training which speeds up training, but also doesn't give you visibility on train metrics. Defaults to False
TYPE:
|
log_debug_plot |
Turning on this parameter plots histograms of the mu, sigma, and pi layers in addition to the logits(if log_logits is turned on in experment config). Defaults to False
TYPE:
|
input_dim |
The input dimensions to the head. This will be automatically filled in while
initializing from the
TYPE:
|