From 1f6d25d8f6405c794a14375acc64d380d36bd0a3 Mon Sep 17 00:00:00 2001 From: BrilliantYuKaimin <91609464+BrilliantYuKaimin@users.noreply.github.com> Date: Wed, 1 Jun 2022 17:31:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20paddle.bernoulli=20?= =?UTF-8?q?=E8=8B=B1=E6=96=87=E6=96=87=E6=A1=A3=20(#42912)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update random.py * test=document_fix * test=document_fix * Update random.py --- python/paddle/tensor/random.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/python/paddle/tensor/random.py b/python/paddle/tensor/random.py index 49671d65b6d..0def896db8f 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 -- GitLab