Type Independent
Namespace tensorflow.contrib.distributions
Parent Distribution
Interfaces IIndependent
Independent distribution from batch of distributions. This distribution is useful for regarding a collection of independent,
non-identical distributions as a single random variable. For example, the
`Independent` distribution composed of a collection of `Bernoulli`
distributions might define a distribution over an image (where each
`Bernoulli` is a distribution over each pixel). More precisely, a collection of `B` (independent) `E`-variate random variables
(rv) `{X_1,..., X_B}`, can be regarded as a `[B, E]`-variate random variable
`(X_1,..., X_B)` with probability
`p(x_1,..., x_B) = p_1(x_1) *... * p_B(x_B)` where `p_b(X_b)` is the
probability of the `b`-th rv. More generally `B, E` can be arbitrary shapes. Similarly, the `Independent` distribution specifies a distribution over `[B,
E]`-shaped events. It operates by reinterpreting the rightmost batch dims as
part of the event dimensions. The `reinterpreted_batch_ndims` parameter
controls the number of batch dims which are absorbed as event dims;
`reinterpreted_batch_ndims < len(batch_shape)`. For example, the `log_prob`
function entails a `reduce_sum` over the rightmost `reinterpreted_batch_ndims`
after calling the base distribution's `log_prob`. In other words, since the
batch dimension(s) index independent distributions, the resultant multivariate
will have independent components. #### Mathematical Details The probability function is, ```none
prob(x; reinterpreted_batch_ndims) = tf.reduce_prod(
dist.prob(x),
axis=-1-range(reinterpreted_batch_ndims))
``` #### Examples
Show Example
import tensorflow_probability as tfp tfd = tfp.distributions # Make independent distribution from a 2-batch Normal. ind = tfd.Independent( distribution=tfd.Normal(loc=[-1., 1], scale=[0.1, 0.5]), reinterpreted_batch_ndims=1) # All batch dims have been "absorbed" into event dims. ind.batch_shape # ==> [] ind.event_shape # ==> [2] # Make independent distribution from a 2-batch bivariate Normal. ind = tfd.Independent( distribution=tfd.MultivariateNormalDiag( loc=[[-1., 1], [1, -1]], scale_identity_multiplier=[1., 0.5]), reinterpreted_batch_ndims=1) # All batch dims have been "absorbed" into event dims. ind.batch_shape # ==> [] ind.event_shape # ==> [2, 2]
Properties
- allow_nan_stats
- allow_nan_stats_dyn
- batch_shape
- batch_shape_dyn
- distribution
- distribution_dyn
- dtype
- dtype_dyn
- event_shape
- event_shape_dyn
- name
- name_dyn
- parameters
- parameters_dyn
- PythonObject
- reinterpreted_batch_ndims
- reinterpreted_batch_ndims_dyn
- reparameterization_type
- reparameterization_type_dyn
- validate_args
- validate_args_dyn