Apply to speak at TensorFlow World. Deadline April 23rd. Propose talk

tfp.bijectors.Invert

Class Invert

Inherits From: Bijector

Bijector which inverts another Bijector.

Example Use: ExpGammaDistribution (see Background & Context) models Y=log(X) where X ~ Gamma.

exp_gamma_distribution = TransformedDistribution(
  distribution=Gamma(concentration=1., rate=2.),
  bijector=bijector.Invert(bijector.Exp())

__init__

__init__(
    bijector,
    validate_args=False,
    name=None
)

Creates a Bijector which swaps the meaning of inverse and forward.

y = self.inverse(x, **kwargs)
return -self.inverse_log_det_jacobian(y, **kwargs)

Args:

  • bijector: Bijector instance.
  • validate_args: Python bool indicating whether arguments should be checked for correctness.
  • name: Python str, name given to ops managed by this object.

Properties

bijector

dtype

dtype of Tensors transformable by this distribution.

forward_min_event_ndims

Returns the minimal number of dimensions bijector.forward operates on.

graph_parents

Returns this Bijector's graph_parents as a Python list.

inverse_min_event_ndims

Returns the minimal number of dimensions bijector.inverse operates on.

is_constant_jacobian

Returns true iff the Jacobian matrix is not a function of x.

Returns:

  • is_constant_jacobian: Python bool.

name

Returns the string name of this Bijector.

validate_args

Returns True if Tensor arguments will be validated.

Methods

__call__

__call__(
    value,
    name=None,
    **kwargs
)

Applies or composes the Bijector, depending on input type.

This is a convenience function which applies the Bijector instance in three different ways, depending on the input:

  1. If the input is a tfd.Distribution instance, return tfd.TransformedDistribution(distribution=input, bijector=self).
  2. If the input is a tfb.Bijector instance, return tfb.Chain([self, input]).
  3. Otherwise, return self.forward(input)

Args:

  • value: A tfd.Distribution, tfb.Bijector, or a Tensor.
  • name: Python str name given to ops created by this function.
  • **kwargs: Additional keyword arguments passed into the created tfd.TransformedDistribution, tfb.Bijector, or self.forward.

Returns:

  • composition: A tfd.TransformedDistribution if the input was a tfd.Distribution, a tfb.Chain if the input was a tfb.Bijector, or a Tensor computed by self.forward.

Examples

sigmoid = tfb.Reciprocal()(
    tfb.AffineScalar(shift=1.)(
      tfb.Exp()(
        tfb.AffineScalar(scale=-1.))))
# ==> `tfb.Chain([
#         tfb.Reciprocal(),
#         tfb.AffineScalar(shift=1.),
#         tfb.Exp(),
#         tfb.AffineScalar(scale=-1.),
#      ])`  # ie, `tfb.Sigmoid()`

log_normal = tfb.Exp()(tfd.Normal(0, 1))
# ==> `tfd.TransformedDistribution(tfd.Normal(0, 1), tfb.Exp())`

tfb.Exp()([-1., 0., 1.])
# ==> tf.exp([-1., 0., 1.])

forward

forward(x)

forward_event_shape

forward_event_shape(input_shape)

forward_event_shape_tensor

forward_event_shape_tensor(input_shape)

forward_log_det_jacobian

forward_log_det_jacobian(
    x,
    event_ndims
)

inverse

inverse(y)

inverse_event_shape

inverse_event_shape(output_shape)

inverse_event_shape_tensor

inverse_event_shape_tensor(output_shape)

inverse_log_det_jacobian

inverse_log_det_jacobian(
    y,
    event_ndims
)