# bernoulli¶

paddle. bernoulli ( x, name=None ) [source]

For each element $$x_i$$ in input x, take a sample from the Bernoulli distribution, also called two-point distribution, with success probability $$x_i$$. The Bernoulli distribution with success probability $$x_i$$ is a discrete probability distribution with probability mass function

$\begin{split}p(y)=\begin{cases} x_i,&y=1\\ 1-x_i,&y=0 \end{cases}.\end{split}$
Parameters
• x (Tensor) – The input Tensor, it’s data type should be float32, float64.

• name (str, optional) – For details, please refer to Name. Generally, no setting is required. Default: None.

Returns

A Tensor filled samples from Bernoulli distribution, whose shape and dtype are same as x.

Return type

Tensor

Examples

import paddle