From d51483f23505e3e049cd317c8a48ec58ae09739b Mon Sep 17 00:00:00 2001 From: Zichun Ye Date: Sat, 8 Jan 2022 17:07:59 +0800 Subject: [PATCH] update nn.prob doc fix typo update doc --- ...pore.nn.probability.bijector.GumbelCDF.rst | 2 +- ...nn.probability.bijector.PowerTransform.rst | 4 +-- ...ore.nn.probability.distribution.Gumbel.rst | 2 +- ....nn.probability.distribution.LogNormal.rst | 2 +- .../nn/probability/bijector/bijector.py | 4 +-- .../mindspore/nn/probability/bijector/exp.py | 8 ++--- .../nn/probability/bijector/gumbel_cdf.py | 8 ++--- .../nn/probability/bijector/invert.py | 12 ------- .../probability/bijector/power_transform.py | 10 +++--- .../nn/probability/bijector/scalar_affine.py | 6 ++-- .../nn/probability/bijector/softplus.py | 6 ++-- .../nn/probability/distribution/bernoulli.py | 8 ++--- .../nn/probability/distribution/beta.py | 7 ++-- .../probability/distribution/categorical.py | 7 ++-- .../nn/probability/distribution/cauchy.py | 7 ++-- .../probability/distribution/distribution.py | 34 +++++++++---------- .../probability/distribution/exponential.py | 7 ++-- .../nn/probability/distribution/gamma.py | 7 ++-- .../nn/probability/distribution/geometric.py | 9 +++-- .../nn/probability/distribution/gumbel.py | 9 +++-- .../nn/probability/distribution/log_normal.py | 9 +++-- .../nn/probability/distribution/logistic.py | 7 ++-- .../nn/probability/distribution/normal.py | 7 ++-- .../nn/probability/distribution/poisson.py | 8 ++--- .../distribution/transformed_distribution.py | 7 ++-- .../nn/probability/distribution/uniform.py | 7 ++-- 26 files changed, 90 insertions(+), 114 deletions(-) diff --git a/docs/api/api_python/nn_probability/mindspore.nn.probability.bijector.GumbelCDF.rst b/docs/api/api_python/nn_probability/mindspore.nn.probability.bijector.GumbelCDF.rst index 31c5acfc4ca..d9d11ea75d1 100644 --- a/docs/api/api_python/nn_probability/mindspore.nn.probability.bijector.GumbelCDF.rst +++ b/docs/api/api_python/nn_probability/mindspore.nn.probability.bijector.GumbelCDF.rst @@ -39,7 +39,7 @@ mindspore.nn.probability.bijector.GumbelCDF >>> >>> # 初始化GumbelCDF Bijector,loc设置为1.0和scale设置为2.0。 >>> gumbel_cdf = msb.GumbelCDF(1.0, 2.0) - >>> # 在网络中使用ScalarAffinebijector。 + >>> # 在网络中使用GumbelCDF bijector。 >>> x = Tensor([1, 2, 3], dtype=mindspore.float32) >>> y = Tensor([0.1, 0.2, 0.3], dtype=mindspore.float32) >>> ans1 = gumbel_cdf.forward(x) diff --git a/docs/api/api_python/nn_probability/mindspore.nn.probability.bijector.PowerTransform.rst b/docs/api/api_python/nn_probability/mindspore.nn.probability.bijector.PowerTransform.rst index 09e6bef0ea3..2ec3757eeb7 100644 --- a/docs/api/api_python/nn_probability/mindspore.nn.probability.bijector.PowerTransform.rst +++ b/docs/api/api_python/nn_probability/mindspore.nn.probability.bijector.PowerTransform.rst @@ -3,7 +3,7 @@ mindspore.nn.probability.bijector.PowerTransform .. py:class:: mindspore.nn.probability.bijector.PowerTransform(power=0., name='PowerTransform') - 乘方Bijector(Power Bijector)。 + 乘方Bijector(PowerTransform Bijector)。 此Bijector对应的映射函数为: .. math:: @@ -11,7 +11,7 @@ mindspore.nn.probability.bijector.PowerTransform 其中幂c >= 0。 - Power Bijector将输入从 `[-1/c, inf]` 映射到 `[0, inf]` 。 + PowerTransform Bijector将输入从 `[-1/c, inf]` 映射到 `[0, inf]` 。 当 `c=0` 时,此Bijector等于 :class:`mindspore.nn.probability.bijector.Exp` Bijector。 diff --git a/docs/api/api_python/nn_probability/mindspore.nn.probability.distribution.Gumbel.rst b/docs/api/api_python/nn_probability/mindspore.nn.probability.distribution.Gumbel.rst index d6780a45be3..3196ee59664 100644 --- a/docs/api/api_python/nn_probability/mindspore.nn.probability.distribution.Gumbel.rst +++ b/docs/api/api_python/nn_probability/mindspore.nn.probability.distribution.Gumbel.rst @@ -15,7 +15,7 @@ mindspore.nn.probability.distribution.Gumbel - **loc** (int, float, list, numpy.ndarray, Tensor) - Gumbel分布的位置。 - **scale** (int, float, list, numpy.ndarray, Tensor) - Gumbel分布的尺度。 - - **seed** (int) - 采样时使用的种子。如果为None,则使用全局种子。默认值:None。 + - **seed** (int) - 采样时使用的种子。如果为None,则使用全局种子。默认值:0。 - **dtype** (mindspore.dtype) - 分布类型。默认值:mindspore.float32。 - **name** (str) - 分布的名称。默认值:'Gumbel'。 diff --git a/docs/api/api_python/nn_probability/mindspore.nn.probability.distribution.LogNormal.rst b/docs/api/api_python/nn_probability/mindspore.nn.probability.distribution.LogNormal.rst index bfe65f23b5c..0093133c0d0 100644 --- a/docs/api/api_python/nn_probability/mindspore.nn.probability.distribution.LogNormal.rst +++ b/docs/api/api_python/nn_probability/mindspore.nn.probability.distribution.LogNormal.rst @@ -16,7 +16,7 @@ mindspore.nn.probability.distribution.LogNormal - **loc** (int, float, list, numpy.ndarray, Tensor) - 基础正态分布的平均值。默认值:None。 - **scale** (int, float, list, numpy.ndarray, Tensor) - 基础正态分布的标准差。默认值:None。 - - **seed** (int) - 采样时使用的种子。如果为None,则使用全局种子。默认值:None。 + - **seed** (int) - 采样时使用的种子。如果为None,则使用全局种子。默认值:0。 - **dtype** (mindspore.dtype) - 分布类型。默认值:mindspore.float32。 - **name** (str) - 分布的名称。默认值:'LogNormal'。 diff --git a/mindspore/python/mindspore/nn/probability/bijector/bijector.py b/mindspore/python/mindspore/nn/probability/bijector/bijector.py index d3e87ca41b5..8f10d54e720 100644 --- a/mindspore/python/mindspore/nn/probability/bijector/bijector.py +++ b/mindspore/python/mindspore/nn/probability/bijector/bijector.py @@ -316,8 +316,8 @@ class Bijector(Cell): Args: name (str): The name of the function. - *args (list): A list of positional arguments that the function needs. - **kwargs (dict): A dictionary of keyword arguments that the function needs. + *args (list): the list of positional arguments forwarded to subclasses. + **kwargs (dict): the dictionary of keyword arguments forwarded to subclasses. """ if name == 'forward': return self.forward(*args, **kwargs) diff --git a/mindspore/python/mindspore/nn/probability/bijector/exp.py b/mindspore/python/mindspore/nn/probability/bijector/exp.py index 8e89755e379..2b35463e4e2 100644 --- a/mindspore/python/mindspore/nn/probability/bijector/exp.py +++ b/mindspore/python/mindspore/nn/probability/bijector/exp.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -"""Power Bijector""" +"""Exp Bijector""" from .power_transform import PowerTransform @@ -28,15 +28,15 @@ class Exp(PowerTransform): name (str): The name of the Bijector. Default: 'Exp'. Inputs and Outputs of APIs: - The accessible api is defined in the base class, including: + The accessible apis of the Exp bijector are defined in the base class, including: - **forward** - **inverse** - **forward_log_jacobian** - **backward_log_jacobian** - It should be notice that the input should be always a tensor. - For more details of all APIs, including the inputs and outputs, + It should be notice that the inputs to the APIs of the Exp bijector should be always a tensor. + For more details of all APIs, including the inputs and outputs of the APIs of the Exp bijector, please refer to :class:`mindspore.nn.probability.bijector.Bijector`, and examples below. Supported Platforms: diff --git a/mindspore/python/mindspore/nn/probability/bijector/gumbel_cdf.py b/mindspore/python/mindspore/nn/probability/bijector/gumbel_cdf.py index 552d1477805..1e87e68c0e8 100644 --- a/mindspore/python/mindspore/nn/probability/bijector/gumbel_cdf.py +++ b/mindspore/python/mindspore/nn/probability/bijector/gumbel_cdf.py @@ -33,16 +33,16 @@ class GumbelCDF(Bijector): name (str): The name of the Bijector. Default: 'GumbelCDF'. Inputs and Outputs of APIs: - The accessible api is defined in the base class, including: + The accessible APIs of the Gumbel_cdf bijector are defined in the base class, including: - **forward** - **inverse** - **forward_log_jacobian** - **backward_log_jacobian** - It should be notice that the input should be always a tensor, + It should be notice that the inputs of APIs of the Gumbel_cdf bijector should be always a tensor, with a shape that can be broadcasted to that of `loc` and `scale`. - For more details of all APIs, including the inputs and outputs, + For more details of all APIs, including the inputs and outputs of APIs of the Gumbel_cdf bijector, please refer to :class:`mindspore.nn.probability.bijector.Bijector`, and examples below. Supported Platforms: @@ -67,7 +67,7 @@ class GumbelCDF(Bijector): >>> >>> # To initialize a GumbelCDF bijector of loc 1.0, and scale 2.0. >>> gumbel_cdf = msb.GumbelCDF(1.0, 2.0) - >>> # To use a ScalarAffine bijector in a network. + >>> # To use a GumbelCDF bijector in a network. >>> x = Tensor([1, 2, 3], dtype=mindspore.float32) >>> y = Tensor([0.1, 0.2, 0.3], dtype=mindspore.float32) >>> ans1 = gumbel_cdf.forward(x) diff --git a/mindspore/python/mindspore/nn/probability/bijector/invert.py b/mindspore/python/mindspore/nn/probability/bijector/invert.py index 9afe57db02e..ac0a4878019 100644 --- a/mindspore/python/mindspore/nn/probability/bijector/invert.py +++ b/mindspore/python/mindspore/nn/probability/bijector/invert.py @@ -26,18 +26,6 @@ class Invert(Bijector): name (str): The name of the Bijector. Default: "". When name is set to "", it is actually 'Invert' + bijector.name. - Inputs and Outputs of APIs: - The accessible api is defined in the base class, including: - - - **forward** - - **inverse** - - **forward_log_jacobian** - - **backward_log_jacobian** - - It should be notice that the input should be always a tensor. - For more details of all APIs, including the inputs and outputs, - please refer to :class:`mindspore.nn.probability.bijector.Bijector`, and examples below. - Supported Platforms: ``Ascend`` ``GPU`` diff --git a/mindspore/python/mindspore/nn/probability/bijector/power_transform.py b/mindspore/python/mindspore/nn/probability/bijector/power_transform.py index e9e4055d190..98e0d1b22eb 100644 --- a/mindspore/python/mindspore/nn/probability/bijector/power_transform.py +++ b/mindspore/python/mindspore/nn/probability/bijector/power_transform.py @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. # ============================================================================ -"""Power Bijector""" +"""PowerTransform Bijector""" from mindspore.ops import operations as P from ..distribution._utils.utils import check_greater_equal_zero from ..distribution._utils.custom_ops import exp_generic, log_generic @@ -21,7 +21,7 @@ from .bijector import Bijector class PowerTransform(Bijector): r""" - Power Bijector. + PowerTransform Bijector. This Bijector performs the operation: .. math:: @@ -38,16 +38,16 @@ class PowerTransform(Bijector): name (str): The name of the bijector. Default: 'PowerTransform'. Inputs and Outputs of APIs: - The accessible api is defined in the base class, including: + The accessible APIs of the PowerTransform bijector are defined in the base class, including: - **forward** - **inverse** - **forward_log_jacobian** - **backward_log_jacobian** - It should be notice that the input should be always a tensor, + It should be notice that the inputs to APIs of the PowerTransform bijector should be always a tensor, with a shape that can be broadcasted to that of `power`. - For more details of all APIs, including the inputs and outputs, + For more details of all APIs, including the inputs and outputs of the PowerTransform bijector, please refer to :class:`mindspore.nn.probability.bijector.Bijector`, and examples below. Supported Platforms: diff --git a/mindspore/python/mindspore/nn/probability/bijector/scalar_affine.py b/mindspore/python/mindspore/nn/probability/bijector/scalar_affine.py index c8159d8265c..8cbc7cd9369 100644 --- a/mindspore/python/mindspore/nn/probability/bijector/scalar_affine.py +++ b/mindspore/python/mindspore/nn/probability/bijector/scalar_affine.py @@ -34,16 +34,16 @@ class ScalarAffine(Bijector): name (str): The name of the bijector. Default: 'ScalarAffine'. Inputs and Outputs of APIs: - The accessible api is defined in the base class, including: + The accessible APIs of the Scalar affine bijector is defined in the base class, including: - **forward** - **inverse** - **forward_log_jacobian** - **backward_log_jacobian** - It should be notice that the input should be always a tensor, + It should be notice that the inputs to APIs of the Scalar affine bijector should be always a tensor, with a shape that can be broadcasted to that of `shift` and `scale`. - For more details of all APIs, including the inputs and outputs, + For more details of all APIs, including the inputs and outputs of APIs of the scalar affine bijector, please refer to :class:`mindspore.nn.probability.bijector.Bijector`, and examples below. Supported Platforms: diff --git a/mindspore/python/mindspore/nn/probability/bijector/softplus.py b/mindspore/python/mindspore/nn/probability/bijector/softplus.py index 7e59d4e8629..a0439aa220c 100644 --- a/mindspore/python/mindspore/nn/probability/bijector/softplus.py +++ b/mindspore/python/mindspore/nn/probability/bijector/softplus.py @@ -35,16 +35,16 @@ class Softplus(Bijector): name (str): The name of the Bijector. Default: 'Softplus'. Inputs and Outputs of APIs: - The accessible api is defined in the base class, including: + The accessible APIs of the Softplus bijector is defined in the base class, including: - **forward** - **inverse** - **forward_log_jacobian** - **backward_log_jacobian** - It should be notice that the input should be always a tensor, + It should be notice that the inputs of APIs of APIs of the Softplus bijector should be always a tensor, with a shape that can be broadcasted to that of `sharpness`. - For more details of all APIs, including the inputs and outputs, + For more details of all APIs, including the inputs and outputs of APIs of the Softplus bijector, please refer to :class:`mindspore.nn.probability.bijector.Bijector`, and examples below. Supported Platforms: diff --git a/mindspore/python/mindspore/nn/probability/distribution/bernoulli.py b/mindspore/python/mindspore/nn/probability/distribution/bernoulli.py index eba9d8c0740..30dfda5397c 100644 --- a/mindspore/python/mindspore/nn/probability/distribution/bernoulli.py +++ b/mindspore/python/mindspore/nn/probability/distribution/bernoulli.py @@ -35,16 +35,15 @@ class Bernoulli(Distribution): name (str): The name of the distribution. Default: 'Bernoulli'. Inputs and Outputs of APIs: - The accessible api is defined in the base class, including: + The accessible APIs of Bernoulli distribution are defined in the base class, including: - `prob`, `log_prob`, `cdf`, `log_cdf`, `survival_function`, and `log_survival` - `mean`, `sd`, `var`, and `entropy` - `kl_loss` and `cross_entropy` - `sample` - It should be notice that the input should be always a tensor. - For more details of all APIs, including the inputs and outputs, - please refer to :class:`mindspore.nn.probability.bijector.Distribution`, and examples below. + For more details of all APIs, including the inputs and outputs of the APIs of the Bernoulli distribution, + please refer to :class:`mindspore.nn.probability.distribution.Distribution`, and examples below. Supported Platforms: ``Ascend`` ``GPU`` @@ -55,7 +54,6 @@ class Bernoulli(Distribution): Raises: ValueError: When p <= 0 or p >=1. - TypeError: When the input `dtype` is not a subclass of float. Examples: >>> import mindspore diff --git a/mindspore/python/mindspore/nn/probability/distribution/beta.py b/mindspore/python/mindspore/nn/probability/distribution/beta.py index 48770b9fcda..3ad0db30485 100644 --- a/mindspore/python/mindspore/nn/probability/distribution/beta.py +++ b/mindspore/python/mindspore/nn/probability/distribution/beta.py @@ -44,16 +44,15 @@ class Beta(Distribution): name (str): The name of the distribution. Default: 'Beta'. Inputs and Outputs of APIs: - The accessible api is defined in the base class, including: + The accessible APIs of the Beta distribution are defined in the base class, including: - `prob` and `log_prob` - `mean`, `sd`, `var`, and `entropy` - `kl_loss` and `cross_entropy` - `sample` - It should be notice that the input should be always a tensor. - For more details of all APIs, including the inputs and outputs, - please refer to :class:`mindspore.nn.probability.bijector.Distribution`, and examples below. + For more details of all APIs, including the inputs and outputs of APIs of the Beta distribution + please refer to :class:`mindspore.nn.probability.distribution.Distribution`, and examples below. Supported Platforms: ``Ascend`` diff --git a/mindspore/python/mindspore/nn/probability/distribution/categorical.py b/mindspore/python/mindspore/nn/probability/distribution/categorical.py index 44b96f82c5f..98efbf259c3 100644 --- a/mindspore/python/mindspore/nn/probability/distribution/categorical.py +++ b/mindspore/python/mindspore/nn/probability/distribution/categorical.py @@ -40,16 +40,15 @@ class Categorical(Distribution): name (str): The name of the distribution. Default: Categorical. Inputs and Outputs of APIs: - The accessible api is defined in the base class, including: + The accessible APIs of the Categorical distribution are defined in the base class, including: - `prob`, `log_prob`, `cdf`, `log_cdf`, `survival_function`, and `log_survival` - `mean`, `sd`, `var`, and `entropy` - `kl_loss` and `cross_entropy` - `sample` - It should be notice that the input should be always a tensor. - For more details of all APIs, including the inputs and outputs, - please refer to :class:`mindspore.nn.probability.bijector.Distribution`, and examples below. + For more details of all APIs, including the inputs and outputs of the APIs of the Categorical distribution, + please refer to :class:`mindspore.nn.probability.distribution.Distribution`, and examples below. Supported Platforms: ``Ascend`` ``GPU`` diff --git a/mindspore/python/mindspore/nn/probability/distribution/cauchy.py b/mindspore/python/mindspore/nn/probability/distribution/cauchy.py index a11716bb5cd..4f09c28e31b 100644 --- a/mindspore/python/mindspore/nn/probability/distribution/cauchy.py +++ b/mindspore/python/mindspore/nn/probability/distribution/cauchy.py @@ -42,16 +42,15 @@ class Cauchy(Distribution): name (str): The name of the distribution. Default: 'Cauchy'. Inputs and Outputs of APIs: - The accessible api is defined in the base class, including: + The accessible APIs of the Cauchy distribution are defined in the base class, including: - `prob`, `log_prob`, `cdf`, `log_cdf`, `survival_function`, and `log_survival` - `mode` and `entropy` - `kl_loss` and `cross_entropy` - `sample` - It should be notice that the input should be always a tensor. - For more details of all APIs, including the inputs and outputs, - please refer to :class:`mindspore.nn.probability.bijector.Distribution`, and examples below. + For more details of all APIs, including the inputs and outputs of the APIs of the Cauchy distribution, + please refer to :class:`mindspore.nn.probability.distribution.Distribution`, and examples below. Supported Platforms: ``Ascend`` diff --git a/mindspore/python/mindspore/nn/probability/distribution/distribution.py b/mindspore/python/mindspore/nn/probability/distribution/distribution.py index eafdc73644c..cb5885524cc 100644 --- a/mindspore/python/mindspore/nn/probability/distribution/distribution.py +++ b/mindspore/python/mindspore/nn/probability/distribution/distribution.py @@ -78,7 +78,7 @@ class Distribution(Cell): # if not a transformed distribution, set the following attribute if 'distribution' not in self.parameters.keys(): self.parameter_type = set_param_type( - self.parameters['param_dict'], dtype) + self.parameters.get('param_dict', {}), dtype) self._batch_shape = self._calc_batch_shape() self._is_scalar_batch = self._check_is_scalar_batch() self._broadcast_shape = self._batch_shape @@ -397,7 +397,7 @@ class Distribution(Cell): **kwargs (dict): the dictionary of keyword arguments forwarded to subclasses. Note: - A distribution can be optionally passed to the function by passing its dist_spec_args through + A distribution can be optionally passed to the function by passing its `dist_spec_args` through `args` or `kwargs`. """ return self._call_log_prob(value, *args, **kwargs) @@ -421,7 +421,7 @@ class Distribution(Cell): **kwargs (dict): the dictionary of keyword arguments forwarded to subclasses. Note: - A distribution can be optionally passed to the function by passing its dist_spec_args through + A distribution can be optionally passed to the function by passing its `dist_spec_args` through `args` or `kwargs`. """ return self._call_prob(value, *args, **kwargs) @@ -445,7 +445,7 @@ class Distribution(Cell): **kwargs (dict): the dictionary of keyword arguments forwarded to subclasses. Note: - A distribution can be optionally passed to the function by passing its dist_spec_args through + A distribution can be optionally passed to the function by passing its `dist_spec_args` through `args` or `kwargs`. Output: @@ -490,7 +490,7 @@ class Distribution(Cell): **kwargs (dict: the dictionary of keyword arguments forwarded to subclasses. Note: - A distribution can be optionally passed to the function by passing its dist_spec_args through + A distribution can be optionally passed to the function by passing its `dist_spec_args` through `args` or `kwargs`. Output: @@ -517,7 +517,7 @@ class Distribution(Cell): **kwargs (dict): the dictionary of keyword arguments forwarded to subclasses. Note: - A distribution can be optionally passed to the function by passing its dist_spec_args through + A distribution can be optionally passed to the function by passing its `dist_spec_args` through `args` or `kwargs`. Output: @@ -553,7 +553,7 @@ class Distribution(Cell): **kwargs (dict): the dictionary of keyword arguments forwarded to subclasses. Note: - A distribution can be optionally passed to the function by passing its dist_spec_args through + A distribution can be optionally passed to the function by passing its `dist_spec_args` through `args` or `kwargs`. Output: @@ -583,8 +583,8 @@ class Distribution(Cell): **kwargs (dict): the dictionary of keyword arguments forwarded to subclasses. Note: - dist_spec_args of distribution b must be passed to the function through `args` or `kwargs`. - Passing in dist_spec_args of distribution a is optional. + `dist_spec_args` of distribution b must be passed to the function through `args` or `kwargs`. + Passing in `dist_spec_args` of distribution a is optional. Output: Tensor, the kl loss function of the distribution. @@ -604,7 +604,7 @@ class Distribution(Cell): Note: A distribution can be optionally passed to the function by passing its *dist_spec_args* through - *args* or *kwargs*. + `args` or `kwargs`. Output: Tensor, the mean of the distribution. @@ -624,7 +624,7 @@ class Distribution(Cell): Note: A distribution can be optionally passed to the function by passing its *dist_spec_args* through - *args* or *kwargs*. + `args` or `kwargs`. Output: Tensor, the mode of the distribution. @@ -641,7 +641,7 @@ class Distribution(Cell): Note: A distribution can be optionally passed to the function by passing its *dist_spec_args* through - *args* or *kwargs*. + `args` or `kwargs`. Output: Tensor, the standard deviation of the distribution. @@ -658,7 +658,7 @@ class Distribution(Cell): Note: A distribution can be optionally passed to the function by passing its *dist_spec_args* through - *args* or *kwargs*. + `args` or `kwargs`. Output: Tensor, the variance of the distribution. @@ -696,7 +696,7 @@ class Distribution(Cell): Note: A distribution can be optionally passed to the function by passing its *dist_spec_args* through - *args* or *kwargs*. + `args` or `kwargs`. Output: Tensor, the entropy of the distribution. @@ -713,8 +713,8 @@ class Distribution(Cell): **kwargs (dict): the dictionary of keyword arguments forwarded to subclasses. Note: - dist_spec_args of distribution b must be passed to the function through `args` or `kwargs`. - Passing in dist_spec_args of distribution a is optional. + `dist_spec_args` of distribution b must be passed to the function through `args` or `kwargs`. + Passing in `dist_spec_args` of distribution a is optional. Output: Tensor, the cross_entropy of two distributions. @@ -744,7 +744,7 @@ class Distribution(Cell): Note: A distribution can be optionally passed to the function by passing its *dist_spec_args* through - *args* or *kwargs*. + `args` or `kwargs`. Output: Tensor, the sample generated from the distribution. diff --git a/mindspore/python/mindspore/nn/probability/distribution/exponential.py b/mindspore/python/mindspore/nn/probability/distribution/exponential.py index d45c70e8f6a..d6804eacbcd 100644 --- a/mindspore/python/mindspore/nn/probability/distribution/exponential.py +++ b/mindspore/python/mindspore/nn/probability/distribution/exponential.py @@ -41,16 +41,15 @@ class Exponential(Distribution): name (str): The name of the distribution. Default: 'Exponential'. Inputs and Outputs of APIs: - The accessible api is defined in the base class, including: + The accessible APIs of the Exp distribution are defined in the base class, including: - `prob`, `log_prob`, `cdf`, `log_cdf`, `survival_function`, and `log_survival` - `mean`, `sd`, `var`, and `entropy` - `kl_loss` and `cross_entropy` - `sample` - It should be notice that the input should be always a tensor. - For more details of all APIs, including the inputs and outputs, - please refer to :class:`mindspore.nn.probability.bijector.Distribution`, and examples below. + For more details of all APIs, including the inputs and outputs of all APIs of the Exp distribution, + please refer to :class:`mindspore.nn.probability.distribution.Distribution`, and examples below. Supported Platforms: ``Ascend`` ``GPU`` diff --git a/mindspore/python/mindspore/nn/probability/distribution/gamma.py b/mindspore/python/mindspore/nn/probability/distribution/gamma.py index 1d78ec9fb5c..1510fe5fbd2 100644 --- a/mindspore/python/mindspore/nn/probability/distribution/gamma.py +++ b/mindspore/python/mindspore/nn/probability/distribution/gamma.py @@ -46,16 +46,15 @@ class Gamma(Distribution): name (str): The name of the distribution. Default: 'Gamma'. Inputs and Outputs of APIs: - The accessible api is defined in the base class, including: + The accessible APIs of the Gamma distribution are defined in the base class, including: - `prob`, `log_prob`, `cdf`, `log_cdf`, `survival_function`, and `log_survival` - `mean`, `sd`, `mode`, `var`, and `entropy` - `kl_loss` and `cross_entropy` - `sample` - It should be notice that the input should be always a tensor. - For more details of all APIs, including the inputs and outputs, - please refer to :class:`mindspore.nn.probability.bijector.Distribution`, and examples below. + For more details of all APIs, including the inputs and outputs of all APIs of the Gamma distribution, + please refer to :class:`mindspore.nn.probability.distribution.Distribution`, and examples below. Supported Platforms: ``Ascend`` diff --git a/mindspore/python/mindspore/nn/probability/distribution/geometric.py b/mindspore/python/mindspore/nn/probability/distribution/geometric.py index 5bb4272b055..39c0eae79ff 100644 --- a/mindspore/python/mindspore/nn/probability/distribution/geometric.py +++ b/mindspore/python/mindspore/nn/probability/distribution/geometric.py @@ -32,22 +32,21 @@ class Geometric(Distribution): trials when the first success is achieved. Args: - probs (int, float, list, numpy.ndarray, Tensor): The probability of success. Default: None. + probs (float, list, numpy.ndarray, Tensor): The probability of success. Default: None. seed (int): The seed used in sampling. Global seed is used if it is None. Default: None. dtype (mindspore.dtype): The type of the event samples. Default: mstype.int32. name (str): The name of the distribution. Default: 'Geometric'. Inputs and Outputs of APIs: - The accessible api is defined in the base class, including: + The accessible APIs of the Geometric distribution are defined in the base class, including: - `prob`, `log_prob`, `cdf`, `log_cdf`, `survival_function`, and `log_survival` - `mean`, `sd`, `mode`, `var`, and `entropy` - `kl_loss` and `cross_entropy` - `sample` - It should be notice that the input should be always a tensor. - For more details of all APIs, including the inputs and outputs, - please refer to :class:`mindspore.nn.probability.bijector.Distribution`, and examples below. + For more details of all APIs, including the inputs and outputs of all APIs of the Geometric distribution, + please refer to :class:`mindspore.nn.probability.distribution.Distribution`, and examples below. Supported Platforms: ``Ascend`` ``GPU`` diff --git a/mindspore/python/mindspore/nn/probability/distribution/gumbel.py b/mindspore/python/mindspore/nn/probability/distribution/gumbel.py index bce5e077ae6..ee3c9ea6f0e 100644 --- a/mindspore/python/mindspore/nn/probability/distribution/gumbel.py +++ b/mindspore/python/mindspore/nn/probability/distribution/gumbel.py @@ -39,18 +39,21 @@ class Gumbel(TransformedDistribution): Args: loc (int, float, list, numpy.ndarray, Tensor): The location of Gumbel distribution. Default: None. scale (int, float, list, numpy.ndarray, Tensor): The scale of Gumbel distribution. Default: None. - seed (int): the seed used in sampling. The global seed is used if it is None. Default: None. + seed (int): the seed used in sampling. The global seed is used if it is None. Default: 0. dtype (mindspore.dtype): type of the distribution. Default: mstype.float32. name (str): the name of the distribution. Default: 'Gumbel'. Inputs and Outputs of APIs: - The accessible api is defined in the base class, including: + The accessible APIs of the Gumbel distribution are defined in the base class, including: - `prob`, `log_prob`, `cdf`, `log_cdf`, `survival_function`, and `log_survival` - `mean`, `sd`, `mode`, `var`, and `entropy` - `kl_loss` and `cross_entropy` - `sample` + For more details of all APIs, including the inputs and outputs of all APIs of the Gumbel distribution, + please refer to :class:`mindspore.nn.probability.distribution.Distribution`, and examples below. + Supported Platforms: ``Ascend`` ``GPU`` @@ -58,13 +61,13 @@ class Gumbel(TransformedDistribution): `scale` must be greater than zero. `dist_spec_args` are `loc` and `scale`. `dtype` must be a float type because Gumbel distributions are continuous. - `kl_loss` and `cross_entropy` are not supported on GPU backend. Raises: ValueError: When scale <= 0. TypeError: When the input `dtype` is not a subclass of float. Examples: + >>> import numpy as np >>> import mindspore >>> import mindspore.nn as nn >>> import mindspore.nn.probability.distribution as msd diff --git a/mindspore/python/mindspore/nn/probability/distribution/log_normal.py b/mindspore/python/mindspore/nn/probability/distribution/log_normal.py index 33fec73e8c0..e55a6b527e9 100644 --- a/mindspore/python/mindspore/nn/probability/distribution/log_normal.py +++ b/mindspore/python/mindspore/nn/probability/distribution/log_normal.py @@ -40,22 +40,21 @@ class LogNormal(msd.TransformedDistribution): loc (int, float, list, numpy.ndarray, Tensor): The mean of the underlying Normal distribution. Default: None. scale (int, float, list, numpy.ndarray, Tensor): The standard deviation of the underlying Normal distribution. Default: None. - seed (int): the seed used in sampling. The global seed is used if it is None. Default: None. + seed (int): the seed used in sampling. The global seed is used if it is None. Default: 0. dtype (mindspore.dtype): type of the distribution. Default: mstype.float32. name (str): the name of the distribution. Default: 'LogNormal'. Inputs and Outputs of APIs: - The accessible api is defined in the base class, including: + The accessible APIs of the Log-Normal distribution are defined in the base class, including: - `prob`, `log_prob`, `cdf`, `log_cdf`, `survival_function`, and `log_survival` - `mean`, `sd`, `mode`, `var`, and `entropy` - `kl_loss` and `cross_entropy` - `sample` - It should be notice that the input should be always a tensor. - For more details of all APIs, including the inputs and outputs, - please refer to :class:`mindspore.nn.probability.bijector.Distribution`, and examples below. + For more details of all APIs, including the inputs and outputs of APIs of the Log-Normal distribution, + please refer to :class:`mindspore.nn.probability.distribution.Distribution`, and examples below. Supported Platforms: ``Ascend`` ``GPU`` diff --git a/mindspore/python/mindspore/nn/probability/distribution/logistic.py b/mindspore/python/mindspore/nn/probability/distribution/logistic.py index 172c27d1a3c..adaf59de3a4 100644 --- a/mindspore/python/mindspore/nn/probability/distribution/logistic.py +++ b/mindspore/python/mindspore/nn/probability/distribution/logistic.py @@ -42,16 +42,15 @@ class Logistic(Distribution): name (str): The name of the distribution. Default: 'Logistic'. Inputs and Outputs of APIs: - The accessible api is defined in the base class, including: + The accessible APIs of the Logistic distribution are defined in the base class, including: - `prob`, `log_prob`, `cdf`, `log_cdf`, `survival_function`, and `log_survival` - `mean`, `sd`, `mode`, `var`, and `entropy` - `kl_loss` and `cross_entropy` - `sample` - It should be notice that the input should be always a tensor. - For more details of all APIs, including the inputs and outputs, - please refer to :class:`mindspore.nn.probability.bijector.Distribution`, and examples below. + For more details of all APIs, including the inputs and outputs of all APIs of the Logistic distribution, + please refer to :class:`mindspore.nn.probability.distribution.Distribution`, and examples below. Supported Platforms: ``Ascend`` ``GPU`` diff --git a/mindspore/python/mindspore/nn/probability/distribution/normal.py b/mindspore/python/mindspore/nn/probability/distribution/normal.py index b5e4ccfc7aa..b194dd4da6b 100644 --- a/mindspore/python/mindspore/nn/probability/distribution/normal.py +++ b/mindspore/python/mindspore/nn/probability/distribution/normal.py @@ -44,16 +44,15 @@ class Normal(Distribution): name (str): The name of the distribution. Default: 'Normal'. Inputs and Outputs of APIs: - The accessible api is defined in the base class, including: + The accessible APIs of the Normal distribution are defined in the base class, including: - `prob`, `log_prob`, `cdf`, `log_cdf`, `survival_function`, and `log_survival` - `mean`, `sd`, `mode`, `var`, and `entropy` - `kl_loss` and `cross_entropy` - `sample` - It should be notice that the input should be always a tensor. - For more details of all APIs, including the inputs and outputs, - please refer to :class:`mindspore.nn.probability.bijector.Distribution`, and examples below. + For more details of all APIs, including the inputs and outputs of all APIs of the Normal distribution, + please refer to :class:`mindspore.nn.probability.distribution.Distribution`, and examples below. Supported Platforms: ``Ascend`` ``GPU`` diff --git a/mindspore/python/mindspore/nn/probability/distribution/poisson.py b/mindspore/python/mindspore/nn/probability/distribution/poisson.py index ed63d8b512c..93be817a110 100644 --- a/mindspore/python/mindspore/nn/probability/distribution/poisson.py +++ b/mindspore/python/mindspore/nn/probability/distribution/poisson.py @@ -38,16 +38,15 @@ class Poisson(Distribution): name (str): The name of the distribution. Default: 'Poisson'. Inputs and Outputs of APIs: - The accessible api is defined in the base class, including: + The accessible APIs of the Poisson distribution are defined in the base class, including: - `prob`, `log_prob`, `cdf`, `log_cdf`, `survival_function`, and `log_survival` - `mean`, `sd`, `mode`, `var`, and `entropy` - `kl_loss` and `cross_entropy` - `sample` - It should be notice that the input should be always a tensor. - For more details of all APIs, including the inputs and outputs, - please refer to :class:`mindspore.nn.probability.bijector.Distribution`, and examples below. + For more details of all APIs, including the inputs and outputs of all APIs of the Poisson distribution, + please refer to :class:`mindspore.nn.probability.distribution.Distribution`, and examples below. Supported Platforms: ``Ascend`` @@ -58,7 +57,6 @@ class Poisson(Distribution): Raises: ValueError: When rate <= 0. - TypeError: When the input `dtype` is not a subclass of float. Examples: >>> import mindspore diff --git a/mindspore/python/mindspore/nn/probability/distribution/transformed_distribution.py b/mindspore/python/mindspore/nn/probability/distribution/transformed_distribution.py index 70b7781215e..475e1345e66 100644 --- a/mindspore/python/mindspore/nn/probability/distribution/transformed_distribution.py +++ b/mindspore/python/mindspore/nn/probability/distribution/transformed_distribution.py @@ -41,15 +41,14 @@ class TransformedDistribution(Distribution): name (str): The name of the transformed distribution. Default: 'transformed_distribution'. Inputs and Outputs of APIs: - The accessible api is defined in the base class, including: + The accessible APIs of the transformed distribution are defined in the base class, including: - `prob`, `log_prob`, `cdf`, `log_cdf`, `survival_function`, and `log_survival` - `mean` - `sample` - It should be notice that the input should be always a tensor. - For more details of all APIs, including the inputs and outputs, - please refer to :class:`mindspore.nn.probability.bijector.Distribution`, and examples below. + For more details of all APIs, including the inputs and outputs of all APIs of the transformed distribution, + please refer to :class:`mindspore.nn.probability.distribution.Distribution`, and examples below. Supported Platforms: ``Ascend`` ``GPU`` diff --git a/mindspore/python/mindspore/nn/probability/distribution/uniform.py b/mindspore/python/mindspore/nn/probability/distribution/uniform.py index 5b6faae58d6..8ada2a97130 100644 --- a/mindspore/python/mindspore/nn/probability/distribution/uniform.py +++ b/mindspore/python/mindspore/nn/probability/distribution/uniform.py @@ -42,16 +42,15 @@ class Uniform(Distribution): name (str): The name of the distribution. Default: 'Uniform'. Inputs and Outputs of APIs: - The accessible api is defined in the base class, including: + The accessible APIs of the Uniform distribution are defined in the base class, including: - `prob`, `log_prob`, `cdf`, `log_cdf`, `survival_function`, and `log_survival` - `mean`, `sd`, `var`, and `entropy` - `kl_loss` and `cross_entropy` - `sample` - It should be notice that the input should be always a tensor. - For more details of all APIs, including the inputs and outputs, - please refer to :class:`mindspore.nn.probability.bijector.Distribution`, and examples below. + For more details of all APIs, including the inputs and outputs of all APIs of the Uniform distribution , + please refer to :class:`mindspore.nn.probability.distribution.Distribution`, and examples below. Supported Platforms: ``Ascend`` ``GPU``