mindelec.vision.MonitorEval

class mindelec.vision.MonitorEval(summary_dir='./summary_eval', model=None, eval_ds=None, eval_interval=10, draw_flag=True)[source]

LossMonitor for eval.

Parameters
  • summary_dir (str) – summary save path. Default: ‘./summary_eval’.

  • model (Solver) – Model object for eval. Default: None.

  • eval_ds (Dataset) – eval dataset. Default: None.

  • eval_interval (int) – eval interval. Default: 10.

  • draw_flag (bool) – specifies if save summary_record. Default: True.

Supported Platforms:

Ascend

Examples

>>> import mindspore.nn as nn
>>> from mindelec.solver import Solver
>>> from mindelec.vision import MonitorEval
>>> class S11Predictor(nn.Cell):
...     def __init__(self, input_dimension):
...         super(S11Predictor, self).__init__()
...         self.fc1 = nn.Dense(input_dimension, 128)
...         self.fc2 = nn.Dense(128, 128)
...         self.fc3 = nn.Dense(128, 1001)
...         self.relu = nn.ReLU()
...
...     def construct(self, x):
...         x0 = x
...         x1 = self.relu(self.fc1(x0))
...         x2 = self.relu(self.fc2(x1))
...         x = self.fc3(x1 + x2)
...         return x
>>> model_net = S11Predictor(3)
>>> model = Solver(network=model_net, mode="Data",
>>>                optimizer=nn.Adam(model_net.trainable_params(), 0.001), loss_fn=nn.MSELoss())
>>> # For details about how to build the dataset, please refer to the tutorial
>>> # document on the official website.
>>> eval_ds = Dataset()
>>> summary_dir = './summary_eval_path'
>>> eval_interval = 10
>>> draw_flag = True
>>> MonitorEval(summary_dir, model, eval_ds, eval_interval, draw_flag)
epoch_end(run_context)[source]

Evaluate the model at the end of epoch.

Parameters

run_context (RunContext) – Context of the train running.