Missed TensorFlow Dev Summit? Check out the video playlist. Watch recordings

tfp.experimental.inference_gym.targets.Banana

View source on GitHub

Creates a banana-shaped distribution.

Inherits From: BayesianModel

tfp.experimental.inference_gym.targets.Banana(
    ndims=2, curvature=0.03, name='banana', pretty_name='Banana'
)

This distribution was first described in [1]. The distribution is constructed by transforming a 2-D normal distribution with scale [10, 1] by shifting the second dimension by curvature * (x0**2 - 100) where x0 is the value of the first dimension. If an N > 2 dimensions are requested, the remaining dimensions are distributed as a standard normal.

This distribution is notable for having relatively narrow tails, while being derived from a simple, volume-preserving transformation of a normal distribution. Despite this simplicity, some inference algorithms have trouble sampling from this distribution.

References

  1. Haario, H., Saksman, E., & Tamminen, J. (1999). Adaptive proposal distribution for random walk Metropolis algorithm. Computational Statistics, 14(3), 375-396.

Args:

  • ndims: Python integer. Dimensionality of the distribution. Must be at least 2.
  • curvature: Python float. Controls the strength of the curvature of the distribution.
  • name: Python str name prefixed to Ops created by this class.
  • pretty_name: A Python str. The pretty name of this model.

Attributes:

  • default_event_space_bijector: Bijector mapping the reals (R**n) to the event space of this model.
  • dtype: The DType of Tensors handled by this model.
  • event_shape: Shape of a single sample from as a TensorShape.

    May be partially defined or unknown.

  • name: Python str name prefixed to Ops created by this class.

  • sample_transformations: A dictionary of names to SampleTransformations.

Raises:

  • ValueError: If ndims < 2.

Child Classes

class SampleTransformation

Methods

evidence

View source

evidence(
    name='evidence'
)

The evidence that the joint model is conditioned on.

joint_distribution

View source

joint_distribution(
    name='joint_distribution'
)

The joint distribution before any conditioning.

sample

View source

sample(
    sample_shape=(), seed=None, name='sample'
)

Generate samples of the specified shape from the target distribution.

The returned samples are exact (and independent) samples from the target distribution of this model.

Args:

  • sample_shape: 0D or 1D int32 Tensor. Shape of the generated samples.
  • seed: Python integer or tfp.util.SeedStream instance, for seeding PRNG.
  • name: Name to give to the prefix the generated ops.

Returns:

  • samples: a Tensor with prepended dimensions sample_shape.

unnormalized_log_prob

View source

unnormalized_log_prob(
    value, name='unnormalized_log_prob'
)

The un-normalized log density of evaluated at a point.

This corresponds to the target distribution associated with the model, often its posterior.

Args:

  • value: A (nest of) Tensor to evaluate the log density at.
  • name: Python str name prefixed to Ops created by this method.

Returns:

  • unnormalized_log_prob: A floating point Tensor.