diff --git a/python/paddle/tensor/random.py b/python/paddle/tensor/random.py index 49671d65b6d44479c8fcf85bb185006731e7db6c..0def896db8f73cd96bb64bba99bd7d7507028c02 100644 --- a/python/paddle/tensor/random.py +++ b/python/paddle/tensor/random.py @@ -30,25 +30,24 @@ __all__ = [] def bernoulli(x, name=None): """ - Returns a Tensor filled with random binary(0 or 1) number from a Bernoulli distribution. - 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:: + 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 - out_i ~ Bernoulli (x_i) + .. math:: + p(y)=\\begin{cases} + x_i,&y=1\\\\ + 1-x_i,&y=0 + \end{cases}. Args: - x(Tensor): A tensor with probabilities for generating the random binary number. The data type - should be float32, float64. - 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`. + x (Tensor): The input Tensor, it's data type should be float32, float64. + name (str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None. + 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``. Examples: .. code-block:: python + :name: bernoulli-example import paddle