!26921 Modify Error Information

Merge pull request !26921 from liuyang/error_ms
This commit is contained in:
i-robot 2021-11-30 02:59:18 +00:00 committed by Gitee
commit f9b9e6add6
2 changed files with 12 additions and 12 deletions

View File

@ -244,8 +244,8 @@ class Cell(Cell_):
@parameter_layout_dict.setter @parameter_layout_dict.setter
def parameter_layout_dict(self, value): def parameter_layout_dict(self, value):
if not isinstance(value, dict): if not isinstance(value, dict):
raise TypeError("The type of parameter 'value' must be a dict type, " raise TypeError(f"For 'Cell', the property 'parameter_layout_dict' must be dict type, "
"but got the type : {}.".format(type(value))) f"but got type {type(value)}.")
self._parameter_layout_dict = value self._parameter_layout_dict = value
@property @property
@ -255,8 +255,8 @@ class Cell(Cell_):
@parallel_parameter_name_list.setter @parallel_parameter_name_list.setter
def parallel_parameter_name_list(self, value): def parallel_parameter_name_list(self, value):
if not isinstance(value, list): if not isinstance(value, list):
raise TypeError("The type of parameter 'parallel_parameter_name_list' must be a list type, " raise TypeError(f"For 'Cell', the property 'parallel_parameter_name_list' must be list type, "
"but got the type : {}.".format(type(value))) f"but got type {type(value)}.")
self._parallel_parameter_name_list = value self._parallel_parameter_name_list = value
@property @property
@ -265,13 +265,13 @@ class Cell(Cell_):
@pipeline_stage.setter @pipeline_stage.setter
def pipeline_stage(self, value): def pipeline_stage(self, value):
if not isinstance(value, int) or isinstance(value, bool): if not isinstance(value, int):
raise TypeError("The parameter 'pipeline_stage' must be an int type, " raise TypeError(f"For 'Cell', the property 'pipeline_stage' must be int type, "
"but got the type : {}.".format(type(value))) f"but got type {type(value)}.")
if value < 0: if value < 0:
raise TypeError("The parameter 'pipeline_stage' can not be less than 0, " raise TypeError("For 'Cell', the property 'pipeline_stage' can not be less than 0, "
"but got the value : {}".format(value)) "but got {}".format(value))
self._pipeline_stage = value self._pipeline_stage = value
for item in self.trainable_params(): for item in self.trainable_params():
item.add_pipeline_stage(value) item.add_pipeline_stage(value)
@ -283,8 +283,8 @@ class Cell(Cell_):
@parallel_parameter_merge_net_dict.setter @parallel_parameter_merge_net_dict.setter
def parallel_parameter_merge_net_dict(self, value): def parallel_parameter_merge_net_dict(self, value):
if not isinstance(value, dict): if not isinstance(value, dict):
raise TypeError("The parameter 'parallel_parameter_merge_net_dict' must be a dict type, " raise TypeError(f"For 'Cell', the property 'parallel_parameter_merge_net_dict' must be dict type, "
"but got the type : {}".format(type(value))) f"but got type {type(value)}.")
self._parallel_parameter_merge_net_dict = value self._parallel_parameter_merge_net_dict = value
def get_func_graph_proto(self): def get_func_graph_proto(self):

View File

@ -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, " raise ValueError(f"For 'Optimizer', the dim of Tensor type 'learning_rate' should be a 0 or 1, "
f"but got {learning_rate.ndim}.") f"but got {learning_rate.ndim}.")
if learning_rate.ndim == 1 and learning_rate.size < 2: 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.") "of elements in the tensor is greater than 1.")
return learning_rate return learning_rate
if isinstance(learning_rate, LearningRateSchedule): if isinstance(learning_rate, LearningRateSchedule):