mindformers.core.callback.MFLossMonitor

class mindformers.core.callback.MFLossMonitor(learning_rate: Union[float, mindspore.nn.learning_rate_schedule.LearningRateSchedule, None] = None, per_print_times: int = 1, micro_batch_num: int = 1, micro_batch_interleave_num: int = 1, origin_epochs: int = None, dataset_size: int = None, initial_epoch: int = 0)[源代码]

Loss Monitor for classification.

参数
  • learning_rate (Union[float, LearningRateSchedule], optional) – The learning rate schedule. Default: None.

  • per_print_times (int) – Every how many steps to print the log information. Default: 1.

  • micro_batch_num (int) – MicroBatch size for Pipeline Parallel. Default: 1.

  • micro_batch_interleave_num (int) – split num of batch size. Default: 1.

  • origin_epochs (int) – Training epoches. Default: None.

  • dataset_size (int) – Training dataset size. Default: None.

实际案例

>>> from mindformers.core.callback import MFLossMonitor
>>> lr = [0.01, 0.008, 0.006, 0.005, 0.002]
>>> monitor = MFLossMonitor(per_print_times=10)
epoch_begin(run_context)[源代码]

Record time at the beginning of epoch.

参数

run_context (RunContext) – Context of the process running.

epoch_end(run_context)[源代码]

Print training info at the end of epoch.

参数

run_context (RunContext) – Context of the process running.

print_output_info(cb_params, cur_epoch_num, origin_epochs, cur_step_num, steps_per_epoch, loss, step_seconds, overflow, scaling_sens)[源代码]

print output information.

step_begin(run_context)[源代码]

Record time at the beginning of step.

参数

run_context (RunContext) – Context of the process running.

step_end(run_context)[源代码]

Print training info at the end of step.

参数

run_context (RunContext) – Context of the process running.