Skip to content

Trainer

EventTrainer

EventTrainer(
    model: EventModel, dp_budget: DpBudget | None = None
)

Trainer for an EventModel.

Parameters:

Name Type Description Default
model EventModel

An EventModel instance.

required
dp_budget DpBudget | None

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.

None

train

train(
    dataset: EventDataset,
    batch_size: int | AutoBatch,
    n_epochs: int | None = None,
    n_steps: int | None = None,
    lr: float = 0.0,
    valid: Validation | None = None,
    hooks: Sequence[TrainHook] = (),
    accumulate_grad: int = 1,
    dp_step: DpStep | None = None,
    world_size: int = 0,
) -> None

Train the EventModel with the input EventDataset.

Parameters:

Name Type Description Default
dataset EventDataset

The training data, as a EventDataset object.

required
batch_size int | AutoBatch

The size of a batch of data during training. It is possible to specify an instance of AutoBatch to automatically estimate the optimal batch size.

required
n_epochs int | None

The number of training epochs. One and only one of n_epochs and n_steps must be provided.

None
n_steps int | None

The number of training steps. One and only one of n_epochs and n_steps must be provided.

None
lr float

The learning rate. If it is 0 the optimal value for the learning rate is automatically determined.

0.0
valid Validation | None

A Validation object. If None, no validation is performed.

None
hooks Sequence[TrainHook]

A sequence of custom TrainHook objects.

()
accumulate_grad int

The number of gradient accumulation steps. If equal to 1, the weights are updated at each step.

1
dp_step DpStep | None

Data for differentially private step. Must be provided if and only if the trainer has a DP-budget.

None
world_size int

Number of GPUs where to distribute the training. If 0, the training is performed on a single device, on the current device of the EventTrainer object.

0

save

save(path: Path | str) -> None

Save the EventTrainer to a checkpoint at the given path.

Parameters:

Name Type Description Default
path Path | str

The path where to save the checkpoint.

required

load classmethod

load(path: Path | str) -> EventTrainer

Load the EventTrainer from the checkpoint at the given path.

Parameters:

Name Type Description Default
path Path | str

The path to the loaded checkpoint.

required

Returns:

Type Description
EventTrainer

The loaded EventTrainer.