!37160 fix bernoulli code docs

Merge pull request !37160 from jiangshuqiang/code_docs_bernoulli
This commit is contained in:
i-robot 2022-07-14 03:17:30 +00:00 committed by Gitee
commit c117c0648c
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
4 changed files with 28 additions and 24 deletions

View File

@ -170,7 +170,7 @@ mindspore.Tensor
**参数:**
- **p** (Union[Tensor, float], 可选) - shape需要可以被广播到当前Tensor。其数据类型为float32或float64。`p` 中每个值代表输出Tensor中对应广播位置为1的概率数值范围在0到1之间。默认值0.5。
- **seed** (int, 可选) - 随机种子,用于生成随机数,数值范围是正数,默认取当前时间。默认值:-1
- **seed** (int, 可选) - 随机种子,用于生成随机数,数值范围是-1或正整数。默认值-1代表取当前时间戳
**返回:**
@ -179,9 +179,9 @@ mindspore.Tensor
**异常:**
- **TypeError** - 当前Tensor的数据类型不在int8, uint8, int16, int32int64bool, float32和float64中。
- **TypeError** - `p` 的数据类型既不是float16也不是float32
- **TypeError** - `p` 的数据类型既不是float32也不是float64
- **TypeError** - `seed` 不是int。
- **ValueError** - `seed` 是负数。
- **ValueError** - `seed` 是负数且不为-1
- **ValueError** - `p` 数值范围不在0到1之间。
.. py:method:: bitwise_and(x)

View File

@ -13,7 +13,7 @@ mindspore.ops.bernoulli
- **x** (Tensor) - 任意维度的Tensor其数据类型为int8, uint8, int16, int32int64bool, float32或float64。
- **p** (Union[Tensor, float], optional) - shape需要可以被广播到当前Tensor。其数据类型为float32或float64。`p` 中每个值代表输出Tensor中对应广播位置为1的概率数值范围在0到1之间。默认值0.5。
- **seed** (int, optional) - 随机种子,用于生成随机数,数值范围是正数,默认取当前时间。默认值:-1
- **seed** (int, optional) - 随机种子,用于生成随机数,数值范围是-1或正整数。默认值-1代表取当前时间戳
**返回:**
@ -22,7 +22,7 @@ mindspore.ops.bernoulli
**异常:**
- **TypeError** - `x` 的数据类型不在int8、uint8、int16、int32、int64、bool、float32和float64中。
- **TypeError** - `p` 的数据类型既不是float16也不是float32
- **TypeError** - `p` 的数据类型既不是float32也不是float64
- **TypeError** - `seed` 不是int。
- **ValueError** - `seed` 是负数。
- **ValueError** - `seed` 是负数且不为-1
- **ValueError** - `p` 数值范围不在0到1之间。

View File

@ -3767,20 +3767,22 @@ class Tensor(Tensor_):
out_{i} \sim Bernoulli(p_{i})
Args:
p (Union[Tensor, float], optional): The shape of p need to be broadcast. The elements of p represent the
probability of setting 1 for the corresponding broadcast position of
the current Tensor. Default: 0.5.
seed (int, optional): The seed value for random generating. Default: -1.
p (Union[Tensor, float], optional): The shape of p need to be broadcast. Data type must be float32 or
float64. The elements of p represent the probability of setting 1 for
the corresponding broadcast position of the current Tensor. The value
of `p` must be in the range `[0, 1]`. Default: 0.5.
seed (int, optional): The seed value for random generating. The value of `seed` must be -1 or a positive
integer. Default: -1, which means using the current timestamp.
Returns:
Tensor, with the same shape and type as x.
output (Tensor), with the same shape and type as x.
Raises:
TypeError: If dtype of Tensor is not one of: int8, uint8, int16, int32int64bool, float32, float64.
TypeError: If dtype of Tensor is not one of: int8, uint8, int16, int32, int64, bool, float32, float64.
TypeError: If dtype of `p` is not one of: float32, float64.
TypeError: If dtype of `seed` is not an int.
TypeError: If dtype of `seed` is not int.
ValueError: If `p` is not in range [0, 1].
ValueError: If `seed` is less than 0.
ValueError: If `seed` is less than 0 and not -1.
Supported Platforms:
``GPU``

View File

@ -3382,21 +3382,23 @@ def bernoulli(x, p=0.5, seed=-1):
Args:
x (Tensor): Tensor of shape :math:`(N,*)` where :math:`*` means, any number of additional dimensions. Data
type must be int8, uint8, int16, int32int64bool, float32 or float64
p (Union[Tensor, float], optional): The shape of p need to be broadcast. The elements of p represent the
probability of setting 1 for the corresponding broadcast position of
the current Tensor. Default: 0.5.
seed (int, optional): The seed value for random generating. Default: -1.
type must be int8, uint8, int16, int32, int64, bool, float32 or float64.
p (Union[Tensor, float], optional): The shape of p need to be broadcast. Data type must be float32 or float64.
The elements of p represent the probability of setting 1 for the
corresponding broadcast position of the current Tensor. The value of `p`
must be in the range `[0, 1]`. Default: 0.5.
seed (int, optional): The seed value for random generating. The value of `seed` must be -1 or a positive
integer. Default: -1, which means using the current timestamp.
Returns:
Tensor, with the same shape and type as x.
output (Tensor), with the same shape and type as x.
Raises:
TypeError: If `seed` is not an int.
TypeError: If dtype of `input` is not one of: int8, uint8, int16, int32int64bool, float32, float64.
TypeError: If dtype of `input` is not one of: float32, float64.
TypeError: If dtype of `x` is not one of: int8, uint8, int16, int32, int64, bool, float32, float64.
TypeError: If dtype of `p` is not one of: float32, float64.
TypeError: If dtype of `seed` is not int.
ValueError: If `p` is not in range [0, 1].
ValueError: If `seed` is less than 0.
ValueError: If `seed` is less than 0 and not -1.
Supported Platforms:
``GPU``