!49533 fix clip_func.py doctest

Merge pull request !49533 from lyqlola/clip
This commit is contained in:
i-robot 2023-03-03 07:46:27 +00:00 committed by Gitee
commit fe36a9fa85
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 12 additions and 10 deletions

View File

@ -109,11 +109,12 @@ def clip_by_value(x, clip_value_min=None, clip_value_max=None):
>>> x = Tensor(np.array([[1., 25., 5., 7.], [4., 11., 6., 21.]]), mindspore.float32)
>>> y = Tensor(np.array([[1., 25., 5., 7.], [4., 11., 6., 21.]]), mindspore.float32)
>>> output = ops.clip_by_value([x,y], min_value, max_value)
>>> print(output)
[[[ 5. 20. 5. 7.]
[ 5. 11. 6. 20.]],
[[ 5. 20. 5. 7.]
[ 5. 11. 6. 20.]]]
>>> for out in output:
... print(out)
[[ 5. 20. 5. 7.]
[ 5. 11. 6. 20.]]
[[ 5. 20. 5. 7.]
[ 5. 11. 6. 20.]]
"""
def _clip_by_value(clip_min, clip_max, x):
if not isinstance(x, Tensor):
@ -211,11 +212,12 @@ def clamp(x, min=None, max=None):
>>> x = Tensor(np.array([[1., 25., 5., 7.], [4., 11., 6., 21.]]), mindspore.float32)
>>> y = Tensor(np.array([[1., 25., 5., 7.], [4., 11., 6., 21.]]), mindspore.float32)
>>> output = ops.clamp([x,y], min_value, max_value)
>>> print(output)
[[[ 5. 20. 5. 7.]
[ 5. 11. 6. 20.]],
[[ 5. 20. 5. 7.]
[ 5. 11. 6. 20.]]]
>>> for out in output:
... print(out)
[[ 5. 20. 5. 7.]
[ 5. 11. 6. 20.]]
[[ 5. 20. 5. 7.]
[ 5. 11. 6. 20.]]
"""
return clip_by_value(x, min, max)