mindspore/docs/api/api_python/train/mindspore.train.OnRequestEx...

70 lines
3.3 KiB
ReStructuredText
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

mindspore.train.OnRequestExit
=============================
.. py:class:: mindspore.train.OnRequestExit(save_ckpt=True, save_mindir=True, file_name='Net', directory='./', sig=signal.SIGUSR1)
响应用户关闭请求退出训练或推理进程保存checkpoint和mindir。
参数:
- **save_ckpt** (bool) - 退出训练或推理进程时是否保存checkpoint。默认值True。
- **save_mindir** (bool) - 退出训练或推理进程时是否保存mindir。默认值True。
- **file_name** (str) - 退出训练或推理进程时保存的checkpoint和mindir的名字checkpoint文件加.ckpt后缀mindir文件加.mindir后缀。默认值'Net'。
- **directory** (str) - 退出训练或推理进程时保存的checkpoint和mindir的目录。默认值'./'。
- **sig** (int) - 退出训练或推理进程时保存的checkpoint和mindir的目录。默认值signal.SIGUSR1。
异常:
- **ValueError** - `save_ckpt` 不是bool值 。
- **ValueError** - `save_mindir` 不是字符串。
- **ValueError** - `file_name` 不是字符串。
- **ValueError** - `directory` 不是字符串。
- **ValueError** - `sig` 不是int数或者是signal.SIGKILL。
.. py:method:: on_train_begin(run_context)
在训练开始时,注册用户传入停止信号的处理程序。
参数:
- **run_context** (RunContext) - 包含模型的相关信息。详情请参考 :class:`mindspore.train.RunContext`
.. py:method:: on_train_step_end(run_context)
在训练step结束时根据是否接收到停止信号`run_context`的`_stop_requested`属性置为True。
参数:
- **run_context** (RunContext) - 包含模型的相关信息。详情请参考 :class:`mindspore.train.RunContext`
.. py:method:: on_train_epoch_end(run_context)
在训练epoch结束时根据是否接收到停止信号`run_context`的`_stop_requested`属性置为True。
参数:
- **run_context** (RunContext) - 包含模型的相关信息。详情请参考 :class:`mindspore.train.RunContext`
.. py:method:: on_train_end(run_context)
在训练结束时根据是否接收到停止信号保存checkpoint或者mindir。
参数:
- **run_context** (RunContext) - 包含模型的相关信息。详情请参考 :class:`mindspore.train.RunContext`
.. py:method:: on_eval_begin(run_context)
在推理开始时,注册用户传入停止信号的处理程序。
参数:
- **run_context** (RunContext) - 包含模型的相关信息。详情请参考 :class:`mindspore.train.RunContext`
.. py:method:: on_eval_step_end(run_context)
在推理step结束时根据是否接收到停止信号`run_context`的`_stop_requested`属性置为True。
参数:
- **run_context** (RunContext) - 包含模型的相关信息。详情请参考 :class:`mindspore.train.RunContext`
.. py:method:: on_eval_end(run_context)
在推理结束时根据是否接收到停止信号保存checkpoint或者mindir。
参数:
- **run_context** (RunContext) - 包含模型的相关信息。详情请参考 :class:`mindspore.train.RunContext`