LostTech.TensorFlow : API Documentation

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

Public properties

object allow_nan_stats get;

object allow_nan_stats_dyn get;

TensorShape batch_shape get;

object batch_shape_dyn get;

object distribution get;

object distribution_dyn get;

object dtype get;

object dtype_dyn get;

TensorShape event_shape get;

object event_shape_dyn get;

string name get;

object name_dyn get;

IDictionary<object, object> parameters get;

object parameters_dyn get;

object PythonObject get;

object reinterpreted_batch_ndims get;

object reinterpreted_batch_ndims_dyn get;

object reparameterization_type get;

object reparameterization_type_dyn get;

object validate_args get;

object validate_args_dyn get;