From 47a52a4d02844dcbbd01230110f627a7754f286b Mon Sep 17 00:00:00 2001 From: liuyang_655 Date: Sun, 28 Nov 2021 22:18:51 -0500 Subject: [PATCH] Modify error info --- mindspore/nn/cell.py | 22 +++++++++++----------- mindspore/nn/optim/optimizer.py | 2 +- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/mindspore/nn/cell.py b/mindspore/nn/cell.py index f8f272444d4..2dd10bf469e 100755 --- a/mindspore/nn/cell.py +++ b/mindspore/nn/cell.py @@ -244,8 +244,8 @@ class Cell(Cell_): @parameter_layout_dict.setter def parameter_layout_dict(self, value): if not isinstance(value, dict): - raise TypeError("The type of parameter 'value' must be a dict type, " - "but got the type : {}.".format(type(value))) + raise TypeError(f"For 'Cell', the property 'parameter_layout_dict' must be dict type, " + f"but got type {type(value)}.") self._parameter_layout_dict = value @property @@ -255,8 +255,8 @@ class Cell(Cell_): @parallel_parameter_name_list.setter def parallel_parameter_name_list(self, value): if not isinstance(value, list): - raise TypeError("The type of parameter 'parallel_parameter_name_list' must be a list type, " - "but got the type : {}.".format(type(value))) + raise TypeError(f"For 'Cell', the property 'parallel_parameter_name_list' must be list type, " + f"but got type {type(value)}.") self._parallel_parameter_name_list = value @property @@ -265,13 +265,13 @@ class Cell(Cell_): @pipeline_stage.setter def pipeline_stage(self, value): - if not isinstance(value, int) or isinstance(value, bool): - raise TypeError("The parameter 'pipeline_stage' must be an int type, " - "but got the type : {}.".format(type(value))) + if not isinstance(value, int): + raise TypeError(f"For 'Cell', the property 'pipeline_stage' must be int type, " + f"but got type {type(value)}.") if value < 0: - raise TypeError("The parameter 'pipeline_stage' can not be less than 0, " - "but got the value : {}".format(value)) + raise TypeError("For 'Cell', the property 'pipeline_stage' can not be less than 0, " + "but got {}".format(value)) self._pipeline_stage = value for item in self.trainable_params(): item.add_pipeline_stage(value) @@ -283,8 +283,8 @@ class Cell(Cell_): @parallel_parameter_merge_net_dict.setter def parallel_parameter_merge_net_dict(self, value): if not isinstance(value, dict): - raise TypeError("The parameter 'parallel_parameter_merge_net_dict' must be a dict type, " - "but got the type : {}".format(type(value))) + raise TypeError(f"For 'Cell', the property 'parallel_parameter_merge_net_dict' must be dict type, " + f"but got type {type(value)}.") self._parallel_parameter_merge_net_dict = value def get_func_graph_proto(self): diff --git a/mindspore/nn/optim/optimizer.py b/mindspore/nn/optim/optimizer.py index f3b369eea85..fa9cc724582 100644 --- a/mindspore/nn/optim/optimizer.py +++ b/mindspore/nn/optim/optimizer.py @@ -398,7 +398,7 @@ class Optimizer(Cell): raise ValueError(f"For 'Optimizer', the dim of Tensor type 'learning_rate' should be a 0 or 1, " f"but got {learning_rate.ndim}.") if learning_rate.ndim == 1 and learning_rate.size < 2: - logger.warning("If use `Tensor` type dynamic learning rate, please make sure that the number" + logger.warning("If use `Tensor` type dynamic learning rate, please make sure that the number " "of elements in the tensor is greater than 1.") return learning_rate if isinstance(learning_rate, LearningRateSchedule):