Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
Synopsis
- data Categorical = Categorical {}
- fromProbs :: Tensor -> Categorical
- fromLogits :: Tensor -> Categorical
Documentation
data Categorical Source #
Creates a categorical distribution parameterized by either :attr:probs
or
| :attr:logits
(but not both).
| .. note::
| It is equivalent to the distribution that :func:`torch.multinomial`
| samples from.
| Samples are integers from :math:`{0, ldots, K-1}` where K
is ``probs.size(-1)``.
| If :attr:probs
is 1D with length-K
, each element is the relative
| probability of sampling the class at that index.
| If :attr:probs
is 2D, it is treated as a batch of relative probability
| vectors.
| .. note:: :attr:probs
must be non-negative, finite and have a non-zero sum,
| and it will be normalized to sum to 1.
| See also: `torch.multinomial`
| Example::
| >>> m = Categorical.fromProbs $ D.asTensor [ 0.25, 0.25, 0.25, 0.25 ]
| >>> Distribution.sample m -- equal probability of 0, 1, 2, 3
| tensor(3)
Instances
Show Categorical Source # | |
Defined in Torch.Distributions.Categorical | |
Distribution Categorical Source # | |
Defined in Torch.Distributions.Categorical batchShape :: Categorical -> [Int] Source # eventShape :: Categorical -> [Int] Source # expand :: Categorical -> [Int] -> Categorical Source # support :: Categorical -> Constraint Source # mean :: Categorical -> Tensor Source # variance :: Categorical -> Tensor Source # sample :: Categorical -> [Int] -> IO Tensor Source # logProb :: Categorical -> Tensor -> Tensor Source # entropy :: Categorical -> Tensor Source # enumerateSupport :: Categorical -> Bool -> Tensor Source # |
fromProbs :: Tensor -> Categorical Source #
fromLogits :: Tensor -> Categorical Source #