Skip to content

Trainers

class TabularTrainer

TabularTrainer.__init__

def __init__(model: TabularModel, dp_budget: DpBudget | None = None) -> None

Trainer for a TabularModel.

Arguments:

  • model - A TabularModel instance.
  • dp_budget - The (eps, delta)-budget for differentially private (DP) training. If None (the default), the training will not be differentially private. Available only for single table datasets.

TabularTrainer.train

def train(dataset: TabularDataset,
n_epochs: int | None = None,
n_steps: int | None = None,
batch_size: int = 0,
lr: float = 0.,
memory: int = 0,
valid: Validation | None = None,
hooks: Sequence[TrainHook] = (),
accumulate_grad: int = 1,
dp_step: DpStep | None = None) -> None

Train the tabular model with the input dataset.

Arguments:

  • dataset - The training data, as a TabularDataset object.
  • n_epochs - The number of training epochs. One and only one of n_epochs and n_steps must be provided.
  • n_steps - The number of training steps. One and only one of n_epochs and n_steps must be provided.
  • batch_size - The size of a batch of data during training. When it is not specified the user must provide the argument memory.
  • lr - The learning rate. If it is 0 the optimal value for the learning rate is automatically determined.
  • memory - The available memory in MB that is used to automatically compute the optimal value of the batch size.
  • valid - A Validation object. If None, no validation is performed.
  • hooks - A sequence of custom TrainHook objects.
  • accumulate_grad - The number of gradient accumulation steps. If equal to 1, the weights are updated at each step.
  • dp_step - Data for differentially private step. Must be provided if and only if the trainer has a DP-budget.

class TextTrainer

TextTrainer.__init__

def __init__(model: TextModel) -> None

Trainer for a TextModel.

Arguments:

  • model - A TextModel instance.

TextTrainer.train

def train(dataset: TextDataset,
n_epochs: int | None = None,
n_steps: int | None = None,
batch_size: int = 0,
lr: float = 0.,
memory: int = 0,
valid: Validation | None = None,
hooks: Sequence[TrainHook] = (),
accumulate_grad: int = 1) -> None

Train the text model with the input dataset.

Arguments:

  • dataset - The training data, as a TextDataset object.
  • n_epochs - The number of training epochs. One and only one of n_epochs and n_steps must be provided.
  • n_steps - The number of training steps. One and only one of n_epochs and n_steps must be provided.
  • batch_size - The size of a batch of data during training. When it is not specified the user must provide the argument memory.
  • lr - The learning rate. If it is 0 the optimal value for the learning rate is automatically determined.
  • memory - The available memory in MB that is used to automatically compute the optimal value of the batch size.
  • valid - A Validation object. If None, no validation is performed.
  • hooks - A sequence of custom TrainHook objects.
  • accumulate_grad - The number of gradient accumulation steps. If equal to 1, the weights are updated at each step.