mindspore.ModelCheckpoint
- class mindspore.ModelCheckpoint(prefix='CKP', directory=None, config=None)[source]
The checkpoint callback class.
It is called to combine with train process and save the model and network parameters after training.
Note
In the distributed training scenario, please specify different directories for each training process to save the checkpoint file. Otherwise, the training may fail. If this callback is used in the model function, the checkpoint file will saved parameters of the optimizer by default.
- Parameters
prefix (str) – The prefix name of checkpoint files. Default: “CKP”.
directory (str) – The path of the folder which will be saved in the checkpoint file. By default, the file is saved in the current directory. Default: None.
config (CheckpointConfig) – Checkpoint strategy configuration. Default: None.
- Raises
ValueError – If prefix is not str or contains the ‘/’ character.
ValueError – If directory is not str.
TypeError – If the config is not CheckpointConfig type.
- end(run_context)[source]
Save the last checkpoint after training finished.
- Parameters
run_context (RunContext) – Context of the train running.
- property latest_ckpt_file_name
Return the latest checkpoint path and file name.
- step_end(run_context)[source]
Save the checkpoint at the end of step.
- Parameters
run_context (RunContext) – Context of the train running.