You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

mindspore.train.callback.ModelCheckpoint.rst 1.4 kB

4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142
  1. .. py:class:: mindspore.train.callback.ModelCheckpoint(prefix='CKP', directory=None, config=None)
  2. checkpoint的回调函数。
  3. 在训练过程中调用该方法可以保存网络参数。
  4. .. note::
  5. 在分布式训练场景下,请为每个训练进程指定不同的目录来保存checkpoint文件。否则,可能会训练失败。
  6. **参数:**
  7. - **prefix** (str) - checkpoint文件的前缀名称。默认值:CKP。
  8. - **directory** (str) - 保存checkpoint文件的文件夹路径。默认情况下,文件保存在当前目录下。默认值:None。
  9. - **config** (CheckpointConfig) - checkpoint策略配置。默认值:None。
  10. **异常:**
  11. - **ValueError** - 如果prefix参数不是str类型或包含'/'字符。
  12. - **ValueError** - 如果directory参数不是str类型。
  13. - **TypeError** - config不是CheckpointConfig类型。
  14. .. py:method:: end(run_context)
  15. 在训练结束后,会保存最后一个step的checkpoint。
  16. **参数:**
  17. - **run_context** (RunContext) - 包含模型的一些基本信息。
  18. .. py:method:: latest_ckpt_file_name
  19. :property:
  20. 返回最新的checkpoint路径和文件名。
  21. .. py:method:: step_end(run_context)
  22. 在step结束时保存checkpoint。
  23. **参数:**
  24. - **run_context** (RunContext) - 包含模型的一些基本信息。