mindspore2022/docs/api/api_python/train/mindspore.train.callback.Lo...

27 lines
877 B
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.

.. py:class:: mindspore.train.callback.LossMonitor(per_print_times=1, has_trained_epoch=0)
监控训练的loss。
如果loss是NAN或INF则终止训练。
.. note::
如果 `per_print_times` 为0则不打印loss。
**参数:**
- **per_print_times** (int) - 表示每隔多少个step打印一次loss。默认值1。
- **has_trained_epoch** (int) - 表示已经训练了多少个epoch如果设置了该参数LossMonitor将监控该数值之后epoch的loss值。默认值0。
**异常:**
- **ValueError** - 当 `per_print_times` 不是整数或小于零。
- **ValueError** - 当 `has_trained_epoch` 不是整数或小于零。
.. py:method:: step_end(run_context)
step结束时打印训练loss。
**参数:**
- **run_context** (RunContext) - 包含模型的相关信息。