Attend the Women in ML Symposium on December 7

# tfp.substrates.numpy.bijectors.IteratedSigmoidCentered

Stay organized with collections Save and categorize content based on your preferences.

Bijector which applies a Stick Breaking procedure.

Inherits From: `AutoCompositeTensorBijector`, `Bijector`

Given a vector `x`, transform it in to a vector `y` such that `y[i] > 0, sum_i y[i] = 1.`. In other words, takes a vector in `R^{k-1}` (unconstrained space) and maps it to a vector in the unit simplex in `R^{k}`.

This transformation is centered in that it maps the zero vector `[0., 0., ... 0.]` to the center of the simplex `[1/k, ... 1/k]`.

This bijector arises from the stick-breaking procedure for constructing a Dirichlet distribution / Dirichlet process as defined in [Stan, 2018][1].

#### Example Use:

``````
bijector.IteratedSigmoidCentered().forward([0., 0., 0.])
# Result: [0.25, 0.25, 0.25, 0.25]
# Extra result: 0.25

bijector.IteratedSigmoidCentered().inverse([0.25, 0.25, 0.25, 0.25])
# Result: [0., 0., 0.]
# Extra coordinate removed.
``````

At first blush it may seem like the Invariance of domain theorem implies this implementation is not a bijection. However, the appended dimension makes the (forward) image non-open and the theorem does not directly apply.

#### References

[1]: Stan Development Team. 2018. Stan Modeling Language Users Guide and Reference Manual, Version 2.18.0. http://mc-stan.org

`graph_parents` Python list of graph prerequisites of this `Bijector`.
`is_constant_jacobian` Python `bool` indicating that the Jacobian matrix is not a function of the input.
`validate_args` Python `bool`, default `False`. Whether to validate input with asserts. If `validate_args` is `False`, and the inputs are invalid, correct behavior is not guaranteed.
`dtype` `tf.dtype` supported by this `Bijector`. `None` means dtype is not enforced. For multipart bijectors, this value is expected to be the same for all elements of the input and output structures.
`forward_min_event_ndims` Python `integer` (structure) indicating the minimum number of dimensions on which `forward` operates.
`inverse_min_event_ndims` Python `integer` (structure) indicating the minimum number of dimensions on which `inverse` operates. Will be set to `forward_min_event_ndims` by default, if no value is provided.
`experimental_use_kahan_sum` Python `bool`. When `True`, use Kahan summation to aggregate log-det jacobians from independent underlying log-det jacobian values, which improves against the precision of a naive float32 sum. This can be noticeable in particular for large dimensions in float32. See CPU caveat on `tfp.math.reduce_kahan_sum`.
`parameters` Python `dict` of parameters used to instantiate this `Bijector`. Bijector instances with identical types, names, and `parameters` share an input/output cache. `parameters` dicts are keyed by strings and are identical if their keys are identical and if corresponding values have identical hashes (or object ids, for unhashable objects).
`name` The name to give Ops created by the initializer.

`ValueError` If neither `forward_min_event_ndims` and `inverse_min_event_ndims` are specified, or if either of them is negative.
`ValueError` If a member of `graph_parents` is not a `Tensor`.

`dtype`

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

Multipart bijectors return structured `ndims`, which indicates the expected structure of their inputs. Some multipart bijectors, notably Composites, may return structures of `None`.

`graph_parents` Returns this `Bijector`'s graph_parents as a Python list.
`has_static_min_event_ndims` Returns True if the bijector has statically-known `min_event_ndims`.
`inverse_min_event_ndims` Returns the minimal number of dimensions bijector.inverse operates on.

Multipart bijectors return structured `event_ndims`, which indicates the expected structure of their outputs. Some multipart bijectors, notably Composites, may return structures of `None`.

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

`name` Returns the string name of this `Bijector`.
`parameters` Dictionary of parameters used to instantiate this `Bijector`.
`trainable_variables`

`validate_args` Returns True if Tensor arguments will be validated.
`variables`

## Methods

### `copy`

View source

Creates a copy of the bijector.

Args
`**override_parameters_kwargs` String/value dictionary of initialization arguments to override with new values.

Returns
`bijector` A new instance of `type(self)` initialized from the union of self.parameters and override_parameters_kwargs, i.e., `dict(self.parameters, **override_parameters_kwargs)`.

### `experimental_batch_shape`

View source

Returns the batch shape of this bijector for inputs of the given rank.

The batch shape of a bijector decribes the set of distinct transformations it represents on events of a given size. For example: the bijector `tfb.Scale([1., 2.])` has batch shape `[2]` for scalar events (`event_ndims = 0`), because applying it to a scalar event produces two scalar outputs, the result of two different scaling transformations. The same bijector has batch shape `[]` for vector events, because applying it to a vector produces (via elementwise multiplication) a single vector output.

Bijectors that operate independently on multiple state parts, such as `tfb.JointMap`, must broadcast to a coherent batch shape. Some events may not be valid: for example, the bijector `tfd.JointMap([tfb.Scale([1., 2.]), tfb.Scale([1., 2., 3.])])` does not produce a valid batch shape when `event_ndims = [0, 0]`, since the batch shapes of the two parts are inconsistent. The same bijector does define valid batch shapes of `[]`, `[2]`, and `[3]` if `event_ndims` is `[1, 1]`, `[0, 1]`, or `[1, 0]`, respectively.

Since transforming a single event produces a scalar log-det-Jacobian, the batch shape of a bijector with non-constant Jacobian is expected to equal the shape of `forward_log_det_jacobian(x, event_ndims=x_event_ndims)` or `inverse_log_det_jacobian(y, event_ndims=y_event_ndims)`, for `x` or `y` of the specified `ndims`.

Args
`x_event_ndims` Optional Python `int` (structure) number of dimensions in a probabilistic event passed to `forward`; this must be greater than or equal to `self.forward_min_event_ndims`. If `None`, defaults to `self.forward_min_event_ndims`. Mutually exclusive with `y_event_ndims`. Default value: `None`.
`y_event_ndims` Optional Python `int` (structure) number of dimensions in a probabilistic event passed to `inverse`; this must be greater than or equal to `self.inverse_min_event_ndims`. Mutually exclusive with `x_event_ndims`. Default value: `None`.

Returns
`batch_shape` `TensorShape` batch shape of this bijector for a value with the given event rank. May be unknown or partially defined.

### `experimental_batch_shape_tensor`

View source

Returns the batch shape of this bijector for inputs of the given rank.

The batch shape of a bijector decribes the set of distinct transformations it represents on events of a given size. For example: the bijector `tfb.Scale([1., 2.])` has batch shape `[2]` for scalar events (`event_ndims = 0`), because applying it to a scalar event produces two scalar outputs, the result of two different scaling transformations. The same bijector has batch shape `[]` for vector events, because applying it to a vector produces (via elementwise multiplication) a single vector output.

Bijectors that operate independently on multiple state parts, such as `tfb.JointMap`, must broadcast to a coherent batch shape. Some events may not be valid: for example, the bijector `tfd.JointMap([tfb.Scale([1., 2.]), tfb.Scale([1., 2., 3.])])` does not produce a valid batch shape when `event_ndims = [0, 0]`, since the batch shapes of the two parts are inconsistent. The same bijector does define valid batch shapes of `[]`, `[2]`, and `[3]` if `event_ndims` is `[1, 1]`, `[0, 1]`, or `[1, 0]`, respectively.

Since transforming a single event produces a scalar log-det-Jacobian, the batch shape of a bijector with non-constant Jacobian is expected to equal the shape of `forward_log_det_jacobian(x, event_ndims=x_event_ndims)` or `inverse_log_det_jacobian(y, event_ndims=y_event_ndims)`, for `x` or `y` of the specified `ndims`.

Args
`x_event_ndims` Optional Python `int` (structure) number of dimensions in a probabilistic event passed to `forward`; this must be greater than or equal to `self.forward_min_event_ndims`. If `None`, defaults to `self.forward_min_event_ndims`. Mutually exclusive with `y_event_ndims`. Default value: `None`.
`y_event_ndims` Optional Python `int` (structure) number of dimensions in a probabilistic event passed to `inverse`; this must be greater than or equal to `self.inverse_min_event_ndims`. Mutually exclusive with `x_event_ndims`. Default value: `None`.

Returns
`batch_shape_tensor` integer `Tensor` batch shape of this bijector for a value with the given event rank.

### `experimental_compute_density_correction`

View source

Density correction for this transformation wrt the tangent space, at x.

Subclasses of Bijector may call the most specific applicable method of `TangentSpace`, based on whether the transformation is dimension-p