Skip to content

Trainer

EventTrainer

__init__

__init__(
    model: EventModel, dp_budget: DpBudget | None = 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,
    n_epochs: int | None = None,
    n_steps: int | None = None,
    batch_size: int = 0,
    lr: float = 0.0,
    memory: int = 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
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
batch_size int

The size of a batch of data during training. When it is not specified the user must provide the argument memory.

0
lr float

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

0.0
memory int

The available memory in MB that is used to automatically compute the optimal value of the batch size.

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 sve 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.