!8966 solve operation issue

From: @jiangzg001
Reviewed-by: @liangchenghui,@kingxian,@liangchenghui
Signed-off-by: @liangchenghui,@liangchenghui
This commit is contained in:
mindspore-ci-bot 2020-11-25 15:11:14 +08:00 committed by Gitee
commit a95cbdb121
2 changed files with 6 additions and 5 deletions

View File

@ -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)

View File

@ -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.