From ecc92b91f829bec3d3ba85a3efd2043b749804de Mon Sep 17 00:00:00 2001 From: luoyuan Date: Thu, 3 Nov 2022 20:17:58 +0800 Subject: [PATCH] [MS][OPS] code docs fix standard_normal ops parameter --- .../ops/mindspore.ops.func_standard_normal.rst | 7 ++++--- mindspore/python/mindspore/ops/function/random_func.py | 10 ++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/docs/api/api_python/ops/mindspore.ops.func_standard_normal.rst b/docs/api/api_python/ops/mindspore.ops.func_standard_normal.rst index f2f2d881b49..daa6ad462b5 100644 --- a/docs/api/api_python/ops/mindspore.ops.func_standard_normal.rst +++ b/docs/api/api_python/ops/mindspore.ops.func_standard_normal.rst @@ -11,7 +11,7 @@ mindspore.ops.standard_normal f(x)=\frac{1}{\sqrt{2 \pi}} e^{\left(-\frac{x^{2}}{2}\right)} 参数: - - **shape** (tuple) - 目标随机数Tensor的shape。只允许常量值。 + - **shape** (Union[tuple, Tensor]) - 待生成的Tensor的shape。当为tuple类型时,只支持常量值;当为Tensor类型时,支持动态Shape。 - **seed** (int) - 随机种子,非负值。默认值:0。 - **seed2** (int) - 随机种子2,用来防止随机种子冲突,非负值。默认值:0。 @@ -20,5 +20,6 @@ mindspore.ops.standard_normal 异常: - **TypeError** - `seed` 或 `seed2` 不是int类型。 - - **TypeError** - `shape` 不是Tuple。 - - **ValueError** - `shape` 不是常量值。 + - **TypeError** - `shape` 既不是tuple,也不是Tensor。 + - **ValueError** - `seed` 或 `seed2` 不是非负的int。 + - **ValueError** - `shape` 为tuple时,包含非正的元素。 diff --git a/mindspore/python/mindspore/ops/function/random_func.py b/mindspore/python/mindspore/ops/function/random_func.py index ee7dfc6b942..bdafca65a21 100755 --- a/mindspore/python/mindspore/ops/function/random_func.py +++ b/mindspore/python/mindspore/ops/function/random_func.py @@ -249,17 +249,19 @@ def standard_normal(shape, seed=0, seed2=0): f(x)=\frac{1}{\sqrt{2 \pi}} e^{\left(-\frac{x^{2}}{2}\right)} Args: - shape (tuple): The shape of random tensor to be generated. Only constant value is allowed. + shape (Union[tuple, Tensor]): The shape of random tensor to be generated. Only constant value is allowed + when the input type is tuple. And the operator supports dynamic shape only when the input type is Tensor. seed (int): Random seed, must be non-negative. Default: 0. seed2 (int): Random seed2, must be non-negative. A second seed to avoid seed collision. Default: 0. Returns: - Tensor. The shape is the same as the input `shape`. The dtype is float32. + Tensor. The shape that the input 'shape' denotes. The dtype is float32. Raises: TypeError: If `seed` or `seed2` is not an int. - TypeError: If `shape` is not a tuple. - ValueError: If `shape` is not a constant value. + TypeError: If `shape` is neither a tuple nor a Tensor. + ValueError: If `seed` or `seed2` is not a non-negative int. + ValueError: If `shape` is a tuple containing non-positive items. Supported Platforms: ``Ascend`` ``GPU`` ``CPU``