torch.distributions.multinomial.Multinomial 类

class Multinomial(torch.distributions.distribution.Distribution)
 |  Multinomial(total_count=1, probs=None, logits=None, validate_args=None)
 |  
 |  Creates a Multinomial distribution parameterized by :attr:`total_count` and
 |  either :attr:`probs` or :attr:`logits` (but not both). The innermost dimension of
 |  :attr:`probs` indexes over categories. All other dimensions index over batches.
 |  
 |  Note that :attr:`total_count` need not be specified if only :meth:`log_prob` is
 |  called (see example below)
 |  
 |  .. note:: :attr:`probs` must be non-negative, finite and have a non-zero sum,
 |            and it will be normalized to sum to 1.
 |  
 |  -   :meth:`sample` requires a single shared `total_count` for all
 |      parameters and samples.
 |  -   :meth:`log_prob` allows different `total_count` for each parameter and
 |      sample.
 |  
 |  Example::
 |  
 |      >>> m = Multinomial(100, torch.tensor([ 1., 1., 1., 1.]))
 |      >>> x = m.sample()  # equal probability of 0, 1, 2, 3
 |      tensor([ 21.,  24.,  30.,  25.])
 |  
 |      >>> Multinomial(probs=torch.tensor([1., 1., 1., 1.])).log_prob(x)
 |      tensor([-4.1338])
 |  
 |  Args:
 |      total_count (int): number of trials
 |      probs (Tensor): event probabilities
 |      logits (Tensor): event log probabilities
 |  
 |  Method resolution order:
 |      Multinomial
 |      torch.distributions.distribution.Distribution
 |      builtins.object
 |  
 |  Methods defined here:
 |  
 |  __init__(self, total_count=1, probs=None, logits=None, validate_args=None)
 |      Initialize self.  See help(type(self)) for accurate signature.
 |  
 |  expand(self, batch_shape, _instance=None)
 |      Returns a new distribution instance (or populates an existing instance
 |      provided by a derived class) with batch dimensions expanded to
 |      `batch_shape`. This method calls :class:`~torch.Tensor.expand` on
 |      the distribution's parameters. As such, this does not allocate new
 |      memory for the expanded distribution instance. Additionally,
 |      this does not repeat any args checking or parameter broadcasting in
 |      `__init__.py`, when an instance is first created.
 |      
 |      Args:
 |          batch_shape (torch.Size): the desired expanded size.
 |          _instance: new instance provided by subclasses that
 |              need to override `.expand`.
 |      
 |      Returns:
 |          New distribution instance with batch dimensions expanded to
 |          `batch_size`.
 |  
 |  log_prob(self, value)
 |      Returns the log of the probability density/mass function evaluated at
 |      `value`.
 |      
 |      Args:
 |          value (Tensor):
 |  
 |  sample(self, sample_shape=torch.Size([]))
 |      Generates a sample_shape shaped sample or sample_shape shaped batch of
 |      samples if the distribution parameters are batched.
 |  
 |  ----------------------------------------------------------------------
 |  Data descriptors defined here:
 |  
 |  logits
 |  
 |  mean
 |      Returns the mean of the distribution.
 |  
 |  param_shape
 |  
 |  probs
 |  
 |  support
 |      Returns a :class:`~torch.distributions.constraints.Constraint` object
 |      representing this distribution's support.
 |  
 |  variance
 |      Returns the variance of the distribution.
 |  
 |  ----------------------------------------------------------------------
 |  Data and other attributes defined here:
 |  
 |  arg_constraints = {'logits': Real(), 'probs': Simplex()}
 |  
 |  ----------------------------------------------------------------------
 |  Methods inherited from torch.distributions.distribution.Distribution:
 |  
 |  __repr__(self)
 |      Return repr(self).
 |  
 |  cdf(self, value)
 |      Returns the cumulative density/mass function evaluated at
 |      `value`.
 |      
 |      Args:
 |          value (Tensor):
 |  
 |  entropy(self)
 |      Returns entropy of distribution, batched over batch_shape.
 |      
 |      Returns:
 |          Tensor of shape batch_shape.
 |  
 |  enumerate_support(self, expand=True)
 |      Returns tensor containing all values supported by a discrete
 |      distribution. The result will enumerate over dimension 0, so the shape
 |      of the result will be `(cardinality,) + batch_shape + event_shape`
 |      (where `event_shape = ()` for univariate distributions).
 |      
 |      Note that this enumerates over all batched tensors in lock-step
 |      `[[0, 0], [1, 1], ...]`. With `expand=False`, enumeration happens
 |      along dim 0, but with the remaining batch dimensions being
 |      singleton dimensions, `[[0], [1], ..`.
 |      
 |      To iterate over the full Cartesian product use
 |      `itertools.product(m.enumerate_support())`.
 |      
 |      Args:
 |          expand (bool): whether to expand the support over the
 |              batch dims to match the distribution's `batch_shape`.
 |      
 |      Returns:
 |          Tensor iterating over dimension 0.
 |  
 |  icdf(self, value)
 |      Returns the inverse cumulative density/mass function evaluated at
 |      `value`.
 |      
 |      Args:
 |          value (Tensor):
 |  
 |  perplexity(self)
 |      Returns perplexity of distribution, batched over batch_shape.
 |      
 |      Returns:
 |          Tensor of shape batch_shape.
 |  
 |  rsample(self, sample_shape=torch.Size([]))
 |      Generates a sample_shape shaped reparameterized sample or sample_shape
 |      shaped batch of reparameterized samples if the distribution parameters
 |      are batched.
 |  
 |  sample_n(self, n)
 |      Generates n samples or n batches of samples if the distribution
 |      parameters are batched.
 |  
 |  ----------------------------------------------------------------------
 |  Static methods inherited from torch.distributions.distribution.Distribution:
 |  
 |  set_default_validate_args(value)
 |  
 |  ----------------------------------------------------------------------
 |  Data descriptors inherited from torch.distributions.distribution.Distribution:
 |  
 |  __dict__
 |      dictionary for instance variables (if defined)
 |  
 |  __weakref__
 |      list of weak references to the object (if defined)
 |  
 |  batch_shape
 |      Returns the shape over which parameters are batched.
 |  
 |  event_shape
 |      Returns the shape of a single sample (without batching).
 |  
 |  stddev
 |      Returns the standard deviation of the distribution.
 |  
 |  ----------------------------------------------------------------------
 |  Data and other attributes inherited from torch.distributions.distribution.Distribution:
 |  
 |  has_enumerate_support = False
 |  
 |  has_rsample = False

你可能感兴趣的:(代码,pytorch,深度学习,python)