mindspore.nn.probability.distribution.LogNormal

class mindspore.nn.probability.distribution.LogNormal(loc=None, scale=None, seed=0, dtype=mstype.float32, name='LogNormal')[source]

LogNormal distribution. A log-normal (or lognormal) distribution is a continuous probability distribution of a random variable whose logarithm is normally distributed. It is constructed as the exponential transformation of a Normal distribution.

Parameters
  • 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.

  • dtype (mindspore.dtype) – type of the distribution. Default: mstype.float32.

  • name (str) – the name of the distribution. Default: ‘LogNormal’.

Supported Platforms:

Ascend GPU

Note

scale must be greater than zero. dist_spec_args are loc and scale. dtype must be a float type because LogNormal distributions are continuous.

Examples

>>> import numpy as np
>>> import mindspore
>>> import mindspore.nn as nn
>>> import mindspore.nn.probability.distribution as msd
>>> from mindspore import Tensor
>>> class Prob(nn.Cell):
...     def __init__(self):
...         super(Prob, self).__init__()
...         self.ln = msd.LogNormal(np.array([0.3]), np.array([[0.2], [0.4]]), dtype=mindspore.float32)
...     def construct(self, x_):
...         return self.ln.prob(x_)
>>> pdf = Prob()
>>> output = pdf(Tensor([1.0, 2.0], dtype=mindspore.float32))
>>> print(output.shape)
(2, 2)
property loc

Distribution parameter for the pre-transformed mean after casting to dtype.

property scale

Distribution parameter for the pre-transformed standard deviation after casting to dtype.