From 706f32a940573119070b1d7b00bd61df4e2513bc Mon Sep 17 00:00:00 2001 From: liuyang_655 Date: Tue, 8 Sep 2020 16:00:02 +0800 Subject: [PATCH] modify eval --- mindspore/train/model.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/mindspore/train/model.py b/mindspore/train/model.py index 3a1286d1306..41c017a2d37 100755 --- a/mindspore/train/model.py +++ b/mindspore/train/model.py @@ -535,10 +535,9 @@ class Model: """ Training API where the iteration is controlled by python front-end. - When setting pynative mode, the training process will be performed with dataset not sink. + When setting pynative mode or CPU, the training process will be performed with dataset not sink. Note: - CPU is not supported when dataset_sink_mode is true. If dataset_sink_mode is True, epoch of training should be equal to the count of repeat operation in dataset processing. Otherwise, errors could occur since the amount of data is not equal to the required amount of training . @@ -558,7 +557,7 @@ class Model: function respectively. callbacks (list): List of callback objects which should be executed while training. Default: None. dataset_sink_mode (bool): Determines whether to pass the data through dataset channel. Default: True. - Configure pynative mode, the training process will be performed with + Configure pynative mode or CPU, the training process will be performed with dataset not sink. sink_size (int): Control the amount of data in each sink. If sink_size = -1, sink the complete dataset for each epoch. @@ -667,10 +666,9 @@ class Model: """ Evaluation API where the iteration is controlled by python front-end. - Configure to pynative mode, the evaluation will be performed with dataset non-sink mode. + Configure to pynative mode or CPU, the evaluating process will be performed with dataset non-sink mode. Note: - CPU is not supported when dataset_sink_mode is true. If dataset_sink_mode is True, data will be sent to device. If device is Ascend, features of data will be transferred one by one. The limitation of data transmission per time is 256M. @@ -708,6 +706,11 @@ class Model: self._clear_metrics() + if context.get_context("device_target") == "CPU": + dataset_sink_mode = False + logger.warning("CPU cannot support dataset sink mode currently." + "So the evaluating process will be performed with dataset non-sink mode.") + with _CallbackManager(callbacks) as list_callback: if dataset_sink_mode: return self._eval_dataset_sink_process(valid_dataset, list_callback, cb_params)