Returns a Tensor filled with random binary(0 or 1) number from a Bernoulli distribution.
For each element :math:`x_i` in input ``x``, take a sample from the Bernoulli distribution, also called two-point distribution, with success probability :math:`x_i`. The Bernoulli distribution with success probability :math:`x_i` is a discrete probability distribution with probability mass function
The input ``x`` is a tensor with probabilities for generating the random binary number.
Each element in ``x`` should be in [0, 1], and the out is generated by:
.. math::
out_i ~ Bernoulli (x_i)
.. math::
p(y)=\\begin{cases}
x_i,&y=1\\\\
1-x_i,&y=0
\end{cases}.
Args:
Args:
x(Tensor): A tensor with probabilities for generating the random binary number. The data type
x (Tensor): The input Tensor, it's data type should be float32, float64.
should be float32, float64.
name (str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None.
name(str, optional): The default value is None. Normally there is no
need for user to set this property. For more information, please
refer to :ref:`api_guide_Name`.
Returns:
Returns:
Tensor: A Tensor filled with random binary number with the same shape and dtype as ``x``.
Tensor: A Tensor filled samples from Bernoulli distribution, whose shape and dtype are same as ``x``.