Document feedback

Question document fragment

When a question document fragment contains a formula, it is displayed as a space.

Submission type
issue

It's a little complicated...

I'd like to ask someone.

Please select the submission type

Problem type
Specifications and Common Mistakes

- Specifications and Common Mistakes:

- Misspellings or punctuation mistakes,incorrect formulas, abnormal display.

- Incorrect links, empty cells, or wrong formats.

- Chinese characters in English context.

- Minor inconsistencies between the UI and descriptions.

- Low writing fluency that does not affect understanding.

- Incorrect version numbers, including software package names and version numbers on the UI.

Usability

- Usability:

- Incorrect or missing key steps.

- Missing main function descriptions, keyword explanation, necessary prerequisites, or precautions.

- Ambiguous descriptions, unclear reference, or contradictory context.

- Unclear logic, such as missing classifications, items, and steps.

Correctness

- Correctness:

- Technical principles, function descriptions, supported platforms, parameter types, or exceptions inconsistent with that of software implementation.

- Incorrect schematic or architecture diagrams.

- Incorrect commands or command parameters.

- Incorrect code.

- Commands inconsistent with the functions.

- Wrong screenshots.

- Sample code running error, or running results inconsistent with the expectation.

Risk Warnings

- Risk Warnings:

- Lack of risk warnings for operations that may damage the system or important data.

Content Compliance

- Content Compliance:

- Contents that may violate applicable laws and regulations or geo-cultural context-sensitive words and expressions.

- Copyright infringement.

Please select the type of question

Problem description

Describe the bug so that we can quickly locate the problem.

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. The log-normal distribution has the range (0,inf) with the pdf as

f(x,μ,σ)=1/xσ2πexp((ln(x)μ)2/2σ2).

where μ,σ are the mean and the standard deviation of the underlying normal distribution respectively. 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: 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 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

For more details of all APIs, including the inputs and outputs of APIs of the Log-Normal distribution, please refer to mindspore.nn.probability.distribution.Distribution, and examples below.

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.

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
>>> 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)
extend_repr()[source]

Display instance object as string.

property loc

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

Output:

Tensor, the loc parameter of the distribution.

property scale

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

Output:

Tensor, the scale parameter of the distribution.