clipppy.utils.distributions.extra_dimensions

Module Contents

class clipppy.utils.distributions.extra_dimensions.ExtraBatched(base_dist: clipppy.utils.distributions.wrapper._Distribution, extra_shape: clipppy.utils.distributions.wrapper._size, validate_args=None)

Base class for a distribution that delegates to another one.

class clipppy.utils.distributions.extra_dimensions.ExtraDimensions(base_dist: clipppy.utils.distributions.wrapper._Distribution, extra_shape: clipppy.utils.distributions.wrapper._size, batch_shape: clipppy.utils.distributions.wrapper._size = None, event_shape: clipppy.utils.distributions.wrapper._size = None, validate_args=None)

Base class for a distribution that delegates to another one.

entropy(self)

Returns entropy of distribution, batched over batch_shape.

Returns:

Tensor of shape batch_shape.

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

roll_to_right(self, value: torch.Tensor)
rsample(self, sample_shape: clipppy.utils.distributions.wrapper._size = torch.Size())

Generates a sample_shape shaped reparameterized sample or sample_shape shaped batch of reparameterized samples if the distribution parameters are batched.

property sample_dim(self)
class clipppy.utils.distributions.extra_dimensions.ExtraIndependent(base_dist: clipppy.utils.distributions.wrapper._Distribution, extra_shape: clipppy.utils.distributions.wrapper._size, validate_args=None)

Add more event dimensions without consuming existing batch dimensions.

Useful in order to treat multiple samples as a dimension in an event and sum them in the probability and to allow proper plating.

log_prob(self, value)

Returns the log of the probability density/mass function evaluated at value.

Args:

value (Tensor):