Browse Source

fix some error of distribution and bijector

tags/v1.2.0-rc1
bingyaweng 4 years ago
parent
commit
b27a07616e
3 changed files with 7 additions and 11 deletions
  1. +0
    -2
      mindspore/nn/probability/bijector/exp.py
  2. +7
    -7
      mindspore/nn/probability/distribution/geometric.py
  3. +0
    -2
      mindspore/nn/probability/distribution/uniform.py

+ 0
- 2
mindspore/nn/probability/bijector/exp.py View File

@@ -34,8 +34,6 @@ class Exp(PowerTransform):
>>> import mindspore
>>> import mindspore.nn as nn
>>> from mindspore import Tensor
>>> import mindspore.context as context
>>> context.set_context(mode=context.GRAPH_MODE)
>>>
>>> # To initialize an Exp bijector.
>>> exp_bijector = nn.probability.bijector.Exp()


+ 7
- 7
mindspore/nn/probability/distribution/geometric.py View File

@@ -26,7 +26,7 @@ from ._utils.custom_ops import exp_generic, log_generic
class Geometric(Distribution):
"""
Geometric Distribution.
It represents that there are k failures before the first sucess, namely taht there are in total k+1 Bernoulli trails
It represents that there are k failures before the first sucess, namely taht there are in total k+1 Bernoulli trials
when the first success is achieved.

Args:
@@ -62,7 +62,7 @@ class Geometric(Distribution):
>>> # `prob`, `log_prob`, `cdf`, `log_cdf`, `survival_function`, and `log_survival`, have the same arguments as follows.
>>> # Args:
>>> # value (Tensor): the value to be evaluated.
>>> # probs1 (Tensor): the probability of success of a Bernoulli trail. Default: self.probs.
>>> # probs1 (Tensor): the probability of success of a Bernoulli trial. Default: self.probs.
>>> # Examples of `prob`.
>>> # Similar calls can be made to other probability functions
>>> # by replacing `prob` by the name of the function.
@@ -79,7 +79,7 @@ class Geometric(Distribution):
(3,)
>>> # Functions `mean`, `sd`, `var`, and `entropy` have the same arguments.
>>> # Args:
>>> # probs1 (Tensor): the probability of success of a Bernoulli trail. Default: self.probs.
>>> # probs1 (Tensor): the probability of success of a Bernoulli trial. Default: self.probs.
>>> # Examples of `mean`. `sd`, `var`, and `entropy` are similar.
>>> ans = g1.mean() # return 1.0
>>> print(ans.shape)
@@ -94,8 +94,8 @@ class Geometric(Distribution):
>>> # Interfaces of 'kl_loss' and 'cross_entropy' are the same.
>>> # Args:
>>> # dist (str): the name of the distribution. Only 'Geometric' is supported.
>>> # probs1_b (Tensor): the probability of success of a Bernoulli trail of distribution b.
>>> # probs1_a (Tensor): the probability of success of a Bernoulli trail of distribution a. Default: self.probs.
>>> # probs1_b (Tensor): the probability of success of a Bernoulli trial of distribution b.
>>> # probs1_a (Tensor): the probability of success of a Bernoulli trial of distribution a. Default: self.probs.
>>> # Examples of `kl_loss`. `cross_entropy` is similar.
>>> ans = g1.kl_loss('Geometric', probs_b)
>>> print(ans.shape)
@@ -110,7 +110,7 @@ class Geometric(Distribution):
>>> # Examples of `sample`.
>>> # Args:
>>> # shape (tuple): the shape of the sample. Default: ()
>>> # probs1 (Tensor): the probability of success of a Bernoulli trail. Default: self.probs.
>>> # probs1 (Tensor): the probability of success of a Bernoulli trial. Default: self.probs.
>>> ans = g1.sample()
>>> print(ans.shape)
()
@@ -172,7 +172,7 @@ class Geometric(Distribution):
@property
def probs(self):
"""
Return the probability of success of the Bernoulli trail,
Return the probability of success of the Bernoulli trial,
after casting to dtype.
"""
return self._probs


+ 0
- 2
mindspore/nn/probability/distribution/uniform.py View File

@@ -44,11 +44,9 @@ class Uniform(Distribution):

Examples:
>>> import mindspore
>>> import mindspore.context as context
>>> import mindspore.nn as nn
>>> import mindspore.nn.probability.distribution as msd
>>> from mindspore import Tensor
>>> context.set_context(mode=context.GRAPH_MODE)
>>> # To initialize a Uniform distribution of the lower bound 0.0 and the higher bound 1.0.
>>> u1 = msd.Uniform(0.0, 1.0, dtype=mindspore.float32)
>>> # A Uniform distribution can be initialized without arguments.


Loading…
Cancel
Save