From 1004db879c62e055b98604f63c7f7006c2d43723 Mon Sep 17 00:00:00 2001 From: jiangzhenguang Date: Tue, 24 Nov 2020 20:25:24 +0800 Subject: [PATCH] solve operation issue. --- mindspore/ops/composite/clip_ops.py | 9 +++++---- mindspore/ops/composite/math_ops.py | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/mindspore/ops/composite/clip_ops.py b/mindspore/ops/composite/clip_ops.py index 02ac7d3380..92eeeeafb3 100644 --- a/mindspore/ops/composite/clip_ops.py +++ b/mindspore/ops/composite/clip_ops.py @@ -84,7 +84,7 @@ class _ClipByGlobalNorm(Cell): super(_ClipByGlobalNorm, self).__init__() # Add interface. This parameter is not used at present if use_norm is not None: - validator.check_number("use_norm", use_norm, 0.0, Rel.GE, self.cls_name) + raise ValueError("Input 'use_norm' only supports None currently!") validator.check_number("clip_norm", clip_norm, 0.0, Rel.GT, self.cls_name) self.clip_norm = Tensor([clip_norm], mstype.float32) self.hyper_map = C.HyperMap() @@ -108,16 +108,17 @@ def _check_value(clip_norm): def clip_by_global_norm(x, clip_norm=1.0, use_norm=None): r""" Clips tensor values by the ratio of the sum of their norms. + Note: - 'input x' should be a tuple or list of tensors. Otherwise, it will raise an error. + input 'x' should be a tuple or list of tensors. Otherwise, it will raise an error. Args: x (Union(tuple[Tensor], list[Tensor])): Input data to clip. - clip_norm (Union(float, int)): The clipping ratio. Default: 1.0 + clip_norm (Union(float, int)): The clipping ratio, it should be greater than 0. Default: 1.0 use_norm (None): The global norm. Default: None. Currently only none is supported. Returns: - Tensor, a clipped Tensor. + tuple[Tensor], a clipped Tensor. Examples: >>> x1 = np.array([[2., 3.],[1., 2.]]).astype(np.float32) diff --git a/mindspore/ops/composite/math_ops.py b/mindspore/ops/composite/math_ops.py index 0ff299e1f2..2fa0b50f94 100644 --- a/mindspore/ops/composite/math_ops.py +++ b/mindspore/ops/composite/math_ops.py @@ -42,7 +42,7 @@ def count_nonzero(x, axis=(), keep_dims=False, dtype=mstype.int32): Count number of nonzero elements across axis of input tensor Args: - x (Union(tuple[Tensor], list[Tensor])): Input data is used to count non-zero numbers. + x (Tensor): Input data is used to count non-zero numbers. axis (Union[int, tuple(int), list(int)]): The dimensions to reduce. Only constant value is allowed. Default: (), reduce all dimensions. keep_dims (bool): If true, keep these reduced dimensions and the length is 1.