Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 9 additions & 20 deletions docs/api/paddle/bernoulli_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,26 @@ 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,数据类型为 float32float64、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