Skip to content

xlm.utils.checkpoint_with_thinning

ThinningCheckpoint

Bases: ModelCheckpoint

Checkpoint callback that saves after every N steps and keeps checkpoints at K*N step intervals.

Parameters:

Name Type Description Default
keep_multiple int

Keep checkpoints for every keep_multiple * every_n_train_steps

1
dirpath Optional[Union[Path, str]]

directory to save the model file

None
filename Optional[str]

checkpoint filename. Must contain {step} in the pattern

None
every_n_train_steps Optional[int]

Number of training steps between checkpoints

None
**kwargs

Additional arguments passed to ModelCheckpoint

required

Example:: >>> callback = StepBasedCheckpoint( ... dirpath='checkpoints', ... filename='model-{epoch}-{step}', ... every_n_train_steps=1000, ... keep_multiple=10 ... ) # This will: # - Save a checkpoint every 1000 steps # - Keep checkpoints at steps 10000, 20000, etc. # - Delete intermediate checkpoints