From 5458d3cac9a063fc353c31ddd0a592515f8546e2 Mon Sep 17 00:00:00 2001 From: BrilliantYuKaimin <91609464+BrilliantYuKaimin@users.noreply.github.com> Date: Sat, 21 May 2022 10:30:17 +0800 Subject: [PATCH 1/4] Update bernoulli_cn.rst --- docs/api/paddle/bernoulli_cn.rst | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/docs/api/paddle/bernoulli_cn.rst b/docs/api/paddle/bernoulli_cn.rst index cb5b1209fec..a75310db23b 100644 --- a/docs/api/paddle/bernoulli_cn.rst +++ b/docs/api/paddle/bernoulli_cn.rst @@ -5,37 +5,25 @@ bernoulli .. py:function:: paddle.bernoulli(x, name=None) -该OP以输入 ``x`` 为概率,生成一个伯努利分布(0-1分布)的Tensor,输出Tensor的形状和数据类型与输入 ``x`` 相同。 - +对输入 ``x`` 的每一个元素 :math:`x_i`,从以 :math:`x_i` 为参数的伯努利分布(又名两点分布或者 0-1 分布)中抽取一个样本。以 :math:`x_i` 为参数的伯努利分布的概率密度函数是 .. math:: - out_i \sim Bernoulli(p = x_i) + p(y)=\\begin{cases} + x_i,&y=1\\\\ + 1-x_i,&y=0 + \\end{cases}. 参数 :::::::::::: - - **x** (Tensor) - 输入的概率值。数据类型为 ``float32`` 、``float64`` . - - **name** (str, 可选) - 操作的名称(可选,默认值为None)。更多信息请参见 :ref:`api_guide_Name`。 + - **x** (Tensor) - 输入的 Tensor,数据类型为:float32、float64、int32、int64。 + - **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name` ,一般无需设置,默认值为 None。 返回 :::::::::::: - Tensor:伯努利分布的随机Tensor,形状和数据类型为与输入 ``x`` 相同。 + Tensor,由伯努利分布中的样本组成的 Tensor,形状和数据类型与输入 ``x`` 相同。 代码示例 :::::::::::: - -.. code-block:: python - - import paddle - - paddle.seed(100) # on CPU device - x = paddle.rand([2,3]) - print(x) - # [[0.5535528 0.20714243 0.01162981] - # [0.51577556 0.36369765 0.2609165 ]] - - out = paddle.bernoulli(x) - print(out) - # [[0. 0. 0.] - # [1. 1. 0.]] +COPY-FROM: paddle.bernoulli:bernoulli-example From 2473c0d302156a2e4bb5c8e441310bd65f70d26b Mon Sep 17 00:00:00 2001 From: BrilliantYuKaimin <91609464+BrilliantYuKaimin@users.noreply.github.com> Date: Sat, 21 May 2022 12:33:35 +0800 Subject: [PATCH 2/4] Update bernoulli_cn.rst --- docs/api/paddle/bernoulli_cn.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/api/paddle/bernoulli_cn.rst b/docs/api/paddle/bernoulli_cn.rst index a75310db23b..1716e21f4a1 100644 --- a/docs/api/paddle/bernoulli_cn.rst +++ b/docs/api/paddle/bernoulli_cn.rst @@ -6,6 +6,7 @@ bernoulli .. py:function:: paddle.bernoulli(x, name=None) 对输入 ``x`` 的每一个元素 :math:`x_i`,从以 :math:`x_i` 为参数的伯努利分布(又名两点分布或者 0-1 分布)中抽取一个样本。以 :math:`x_i` 为参数的伯努利分布的概率密度函数是 + .. math:: p(y)=\\begin{cases} x_i,&y=1\\\\ From 7da002f0a235093eb6d3fe42ec077af97f24442d Mon Sep 17 00:00:00 2001 From: BrilliantYuKaimin <91609464+BrilliantYuKaimin@users.noreply.github.com> Date: Sat, 21 May 2022 13:32:07 +0800 Subject: [PATCH 3/4] Update bernoulli_cn.rst --- docs/api/paddle/bernoulli_cn.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/api/paddle/bernoulli_cn.rst b/docs/api/paddle/bernoulli_cn.rst index 1716e21f4a1..03317a81fa5 100644 --- a/docs/api/paddle/bernoulli_cn.rst +++ b/docs/api/paddle/bernoulli_cn.rst @@ -8,10 +8,10 @@ bernoulli 对输入 ``x`` 的每一个元素 :math:`x_i`,从以 :math:`x_i` 为参数的伯努利分布(又名两点分布或者 0-1 分布)中抽取一个样本。以 :math:`x_i` 为参数的伯努利分布的概率密度函数是 .. math:: - p(y)=\\begin{cases} + p(y)=\begin{cases} x_i,&y=1\\\\ 1-x_i,&y=0 - \\end{cases}. + \end{cases}. 参数 :::::::::::: From 6395cc774b7421e1a3c4e2472b98443ecaac944d Mon Sep 17 00:00:00 2001 From: BrilliantYuKaimin <91609464+BrilliantYuKaimin@users.noreply.github.com> Date: Mon, 23 May 2022 10:36:07 +0800 Subject: [PATCH 4/4] Update bernoulli_cn.rst --- docs/api/paddle/bernoulli_cn.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/api/paddle/bernoulli_cn.rst b/docs/api/paddle/bernoulli_cn.rst index 03317a81fa5..a14dc7cb8b0 100644 --- a/docs/api/paddle/bernoulli_cn.rst +++ b/docs/api/paddle/bernoulli_cn.rst @@ -16,7 +16,7 @@ bernoulli 参数 :::::::::::: - - **x** (Tensor) - 输入的 Tensor,数据类型为:float32、float64、int32、int64。 + - **x** (Tensor) - 输入的 Tensor,数据类型为 float32、float64、int32 或 int64。 - **name** (str,可选) - 具体用法请参见 :ref:`api_guide_Name` ,一般无需设置,默认值为 None。 返回