mindspore.save_checkpoint

mindspore.save_checkpoint(save_obj, ckpt_file_name, integrated_save=True, async_save=False, append_dict=None, enc_key=None, enc_mode='AES-GCM')[source]

Save checkpoint to a specified file.

Parameters
  • save_obj (Union[Cell, list]) – The cell object or data list(each element is a dictionary, like [{“name”: param_name, “data”: param_data},…], the type of param_name would be string, and the type of param_data would be parameter or Tensor).

  • ckpt_file_name (str) – Checkpoint file name. If the file name already exists, it will be overwritten.

  • integrated_save (bool) – Whether to integrated save in automatic model parallel scene. Default: True

  • async_save (bool) – Whether to open an independent thread to save the checkpoint file. Default: False

  • append_dict (dict) – Additional information that needs to be saved. The key of dict must be str, the value of dict must be one of int, float, bool, string, Parameter or Tensor. Default: None.

  • enc_key (Union[None, bytes]) – Byte type key used for encryption. If the value is None, the encryption is not required. Default: None.

  • enc_mode (str) – This parameter is valid only when enc_key is not set to None. Specifies the encryption mode, currently supports ‘AES-GCM’ and ‘AES-CBC’. Default: ‘AES-GCM’.

Raises

TypeError – If the parameter save_obj is not nn.Cell or list type. And if the parameter integrated_save and async_save are not bool type. If the parameter ckpt_file_name is not string type.

Examples

>>> import mindspore as ms
>>>
>>> net = Net()
>>> ms.save_checkpoint(net, "lenet.ckpt")