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.Gumbel

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

Gumbel distribution. A Gumbel distributio is a continuous distribution with the range of all real numbers and the probability density function:

f(x,a,b)=1/bexp(exp((xa)/b)x)

Where a,b are loc and scale parameter respectively.

Parameters

Note

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

Raises
  • ValueError – When scale <= 0.

  • TypeError – When the input dtype is not a subclass of float.

Supported Platforms:

Ascend GPU

Examples

>>> import mindspore
>>> import numpy as np
>>> import mindspore.nn.probability.distribution as msd
>>> import mindspore.nn as nn
>>> from mindspore import Tensor
>>> class Prob(nn.Cell):
...     def __init__(self):
...         super(Prob, self).__init__()
...         self.gum = msd.Gumbel(np.array([0.0]), np.array([[1.0], [2.0]]), dtype=mindspore.float32)
...
...     def construct(self, x_):
...         return self.gum.prob(x_)
>>> value = np.array([1.0, 2.0]).astype(np.float32)
>>> pdf = Prob()
>>> output = pdf(Tensor(value, dtype=mindspore.float32))
property loc

Return the loc parameter of the distribution.

Returns

Tensor, the loc parameter of the distribution.

property scale

Return the scale parameter of the distribution.

Returns

Tensor, the scale parameter of the distribution.

cdf(value, loc, scale)

Compute the cumulatuve distribution function(CDF) of the given value.

Parameters
  • value (Tensor) - the value to compute.

  • loc (Tensor) - the loc parameter of the distribution. Default: None .

  • scale (Tensor) - the scale parameter of the distribution. Default: None .

Returns

Tensor, the value of the cumulatuve distribution function for the given input.

cross_entropy(dist, loc_b, scale_b, loc, scale)

Compute the cross entropy of two distribution.

Parameters
  • dist (str) - the type of the other distribution.

  • loc_b (Tensor) - the loc parameter of the other distribution.

  • scale_b (Tensor) - the scale parameter of the other distribution.

  • loc (Tensor) - the loc parameter of the distribution. Default: None .

  • scale (Tensor) - the scale parameter of the distribution. Default: None .

Returns

Tensor, the value of the cross entropy.

entropy(loc, scale)

Compute the value of the entropy.

Parameters
  • loc (Tensor) - the loc parameter of the distribution. Default: None .

  • scale (Tensor) - the scale parameter of the distribution. Default: None .

Returns

Tensor, the value of the entropy.

kl_loss(dist, loc_b, scale_b, loc, scale)

Compute the value of the K-L loss between two distribution, namely KL(a||b).

Parameters
  • dist (str) - the type of the other distribution.

  • loc_b (Tensor) - the loc parameter of the other distribution.

  • scale_b (Tensor) - the scale parameter of the other distribution.

  • loc (Tensor) - the loc parameter of the distribution. Default: None .

  • scale (Tensor) - the scale parameter of the distribution. Default: None .

Returns

Tensor, the value of the K-L loss.

log_cdf(value, loc, scale)

Compute the log value of the cumulatuve distribution function.

Parameters
  • value (Tensor) - the value to compute.

  • loc (Tensor) - the loc parameter of the distribution. Default: None .

  • scale (Tensor) - the scale parameter of the distribution. Default: None .

Returns

Tensor, the log value of the cumulatuve distribution function.

log_prob(value, loc, scale)

the log value of the probability.

Parameters
  • value (Tensor) - the value to compute.

  • loc (Tensor) - the loc parameter of the distribution. Default: None .

  • scale (Tensor) - the scale parameter of the distribution. Default: None .

Returns

Tensor, the log value of the probability.

log_survival(value, loc, scale)

Compute the log value of the survival function.

Parameters
  • value (Tensor) - the value to compute.

  • loc (Tensor) - the loc parameter of the distribution. Default: None .

  • scale (Tensor) - the scale parameter of the distribution. Default: None .

Returns

Tensor, the value of the K-L loss.

mean(loc, scale)

Compute the mean value of the distribution.

Parameters
  • loc (Tensor) - the loc parameter of the distribution. Default: None .

  • scale (Tensor) - the scale parameter of the distribution. Default: None .

Returns

Tensor, the mean of the distribution.

mode(loc, scale)

Compute the mode value of the distribution.

Parameters
  • loc (Tensor) - the loc parameter of the distribution. Default: None .

  • scale (Tensor) - the scale parameter of the distribution. Default: None .

Returns

Tensor, the mode of the distribution.

prob(value, loc, scale)

The probability of the given value. For the continuous distribution, it is the probability density function.

Parameters
  • value (Tensor) - the value to compute.

  • loc (Tensor) - the loc parameter of the distribution. Default: None .

  • scale (Tensor) - the scale parameter of the distribution. Default: None .

Returns

Tensor, the value of the probability.

sample(shape, loc, scale)

Generate samples.

Parameters
  • shape (tuple) - the shape of the sample.

  • loc (Tensor) - the loc parameter of the distribution. Default: None .

  • scale (Tensor) - the scale parameter of the distribution. Default: None .

Returns

Tensor, the sample following the distribution.

sd(loc, scale)

The standard deviation.

Parameters
  • loc (Tensor) - the loc parameter of the distribution. Default: None .

  • scale (Tensor) - the scale parameter of the distribution. Default: None .

Returns

Tensor, the standard deviation of the distribution.

survival_function(value, loc, scale)

Compute the value of the survival function.

Parameters
  • value (Tensor) - the value to compute.

  • loc (Tensor) - the loc parameter of the distribution. Default: None .

  • scale (Tensor) - the scale parameter of the distribution. Default: None .

Returns

Tensor, the value of the survival function.

var(loc, scale)

Compute the variance of the distribution.

Parameters
  • loc (Tensor) - the loc parameter of the distribution. Default: None .

  • scale (Tensor) - the scale parameter of the distribution. Default: None .

Returns

Tensor, the variance of the distribution.