2022-02-28 14:19:59 +08:00
|
|
|
|
.. py:class:: mindspore.train.callback.LossMonitor(per_print_times=1, has_trained_epoch=0)
|
2021-12-02 09:29:36 +08:00
|
|
|
|
|
|
|
|
|
|
监控训练的loss。
|
|
|
|
|
|
|
|
|
|
|
|
如果loss是NAN或INF,则终止训练。
|
|
|
|
|
|
|
2021-12-04 20:36:47 +08:00
|
|
|
|
.. note::
|
2021-12-02 09:29:36 +08:00
|
|
|
|
如果 `per_print_times` 为0,则不打印loss。
|
|
|
|
|
|
|
|
|
|
|
|
**参数:**
|
|
|
|
|
|
|
2021-12-04 20:36:47 +08:00
|
|
|
|
- **per_print_times** (int) - 表示每隔多少个step打印一次loss。默认值:1。
|
2022-03-15 21:56:44 +08:00
|
|
|
|
- **has_trained_epoch** (int) - 表示已经训练了多少个epoch,如果设置了该参数,LossMonitor将监控该数值之后epoch的loss值。默认值:0。
|
2021-12-02 09:29:36 +08:00
|
|
|
|
|
|
|
|
|
|
**异常:**
|
|
|
|
|
|
|
2021-12-04 20:36:47 +08:00
|
|
|
|
- **ValueError** - 当 `per_print_times` 不是整数或小于零。
|
2022-02-22 23:47:50 +08:00
|
|
|
|
- **ValueError** - 当 `has_trained_epoch` 不是整数或小于零。
|
2022-01-13 16:18:53 +08:00
|
|
|
|
|
2021-12-02 09:29:36 +08:00
|
|
|
|
.. py:method:: step_end(run_context)
|
|
|
|
|
|
|
|
|
|
|
|
step结束时打印训练loss。
|
|
|
|
|
|
|
|
|
|
|
|
**参数:**
|
|
|
|
|
|
|
2021-12-28 20:07:42 +08:00
|
|
|
|
- **run_context** (RunContext) - 包含模型的相关信息。
|