You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

mindspore.nn.probability.distribution.Gumbel.rst 2.2 kB

4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. mindspore.nn.probability.distribution.Gumbel
  2. ================================================
  3. .. py:class:: mindspore.nn.probability.distribution.Gumbel(loc, scale, seed=0, dtype=mstype.float32, name='Gumbel')
  4. Gumbel分布(Gumbel distribution)。
  5. 连续随机分布,取值范围为 :math:`(0, \inf)` ,概率密度函数为
  6. .. math::
  7. f(x, a, b) = 1 / b \exp(\exp(-(x - a) / b) - x).
  8. 其中 :math:`a, b` 为分别为Gumbel分布的位置参数和比例参数。
  9. **参数:**
  10. - **loc** (int, float, list, numpy.ndarray, Tensor) - Gumbel分布的位置。
  11. - **scale** (int, float, list, numpy.ndarray, Tensor) - Gumbel分布的尺度。
  12. - **seed** (int) - 采样时使用的种子。如果为None,则使用全局种子。默认值:None。
  13. - **dtype** (mindspore.dtype) - 分布类型。默认值:mindspore.float32。
  14. - **name** (str) - 分布的名称。默认值:'Gumbel'。
  15. **支持平台:**
  16. ``Ascend`` ``GPU``
  17. .. note::
  18. - `scale` 必须大于零。
  19. - `dtype` 必须是浮点类型,因为Gumbel分布是连续的。
  20. - GPU后端不支持 `kl_loss` 和 `cross_entropy` 。
  21. **异常:**
  22. - **ValueError** - `scale` 中元素小于0。
  23. - **TypeError** - `dtype` 不是float的子类。
  24. **样例:**
  25. >>> import mindspore
  26. >>> import mindspore.nn as nn
  27. >>> import mindspore.nn.probability.distribution as msd
  28. >>> from mindspore import Tensor
  29. >>> class Prob(nn.Cell):
  30. ... def __init__(self):
  31. ... super(Prob, self).__init__()
  32. ... self.gum = msd.Gumbel(np.array([0.0]), np.array([[1.0], [2.0]]), dtype=mindspore.float32)
  33. ...
  34. ... def construct(self, x_):
  35. ... return self.gum.prob(x_)
  36. >>> value = np.array([1.0, 2.0]).astype(np.float32)
  37. >>> pdf = Prob()
  38. >>> output = pdf(Tensor(value, dtype=mindspore.float32))
  39. .. py:method:: loc
  40. :property:
  41. 返回分布位置。
  42. **返回:**
  43. Tensor, 分布的位置值。
  44. .. py:method:: scale
  45. :property:
  46. 返回分布比例。
  47. **返回:**
  48. Tensor, 分布的比例值。