!22778 change error info for model

Merge pull request !22778 from wangnan39/change_error_info_for_model
This commit is contained in:
i-robot 2021-09-02 09:56:47 +00:00 committed by Gitee
commit 86e135c838
1 changed files with 9 additions and 1 deletions

View File

@ -258,7 +258,15 @@ class Model:
self._eval_indexes = eval_indexes self._eval_indexes = eval_indexes
else: else:
if self._loss_fn is None: if self._loss_fn is None:
raise ValueError("loss_fn can not be None.") raise ValueError(f"If `metrics` is set, `eval_network` must not be None. Do not set `metrics` if you"
f" don't want an evaluation.\n"
f"If evaluation is required, you need to specify `eval_network`, which will be used in"
f" the framework to evaluate the model.\n"
f"For the simple scenarios with one data, one label and one logits, `eval_network` is"
f" optional, and then you can set `eval_network` or `loss_fn`. For the latter case,"
f" framework will automatically build an evaluation network with `network` and"
f" `loss_fn`.")
self._eval_network = nn.WithEvalCell(self._network, self._loss_fn, self._amp_level in ["O2", "O3", "auto"]) self._eval_network = nn.WithEvalCell(self._network, self._loss_fn, self._amp_level in ["O2", "O3", "auto"])
self._eval_indexes = [0, 1, 2] self._eval_indexes = [0, 1, 2]