Rate this Page

rsample_and_log_prob#

torchrl.modules.distributions.utils.rsample_and_log_prob(distribution: Distribution, sample_shape: Size | tuple[int, ...] = ()) tuple[Any, Tensor | TensorDictBase][source]#

Reparameterize once and score the same draw atomically when supported.

Parameters:
  • distribution (Distribution) – distribution to sample and score.

  • sample_shape (torch.Size or tuple of int, optional) – leading sample dimensions. Defaults to an empty shape.

Returns:

A tuple containing the reparameterized sample and its log probability.