LostTech.TensorFlow : API Documentation

Type MixtureSameFamily

Namespace tensorflow.contrib.distributions

Parent Distribution

Interfaces IMixtureSameFamily

Mixture (same-family) distribution.

The `MixtureSameFamily` distribution implements a (batch of) mixture distribution where all components are from different parameterizations of the same distribution type. It is parameterized by a `Categorical` "selecting distribution" (over `k` components) and a components distribution, i.e., a `Distribution` with a rightmost batch shape (equal to `[k]`) which indexes each (batch of) component.

#### Examples
Show Example
import tensorflow_probability as tfp
            tfd = tfp.distributions 

### Create a mixture of two scalar Gaussians:

gm = tfd.MixtureSameFamily( mixture_distribution=tfd.Categorical( probs=[0.3, 0.7]), components_distribution=tfd.Normal( loc=[-1., 1], # One for each component. scale=[0.1, 0.5])) # And same here.

gm.mean() # ==> 0.4

gm.variance() # ==> 1.018

# Plot PDF. x = np.linspace(-2., 3., int(1e4), dtype=np.float32) import matplotlib.pyplot as plt plt.plot(x, gm.prob(x).eval());

### Create a mixture of two Bivariate Gaussians:

gm = tfd.MixtureSameFamily( mixture_distribution=tfd.Categorical( probs=[0.3, 0.7]), components_distribution=tfd.MultivariateNormalDiag( loc=[[-1., 1], # component 1 [1, -1]], # component 2 scale_identity_multiplier=[.3,.6]))

gm.mean() # ==> array([ 0.4, -0.4], dtype=float32)

gm.covariance() # ==> array([[ 1.119, -0.84], # [-0.84, 1.119]], dtype=float32)

# Plot PDF contours. def meshgrid(x, y=x): [gx, gy] = np.meshgrid(x, y, indexing='ij') gx, gy = np.float32(gx), np.float32(gy) grid = np.concatenate([gx.ravel()[None, :], gy.ravel()[None, :]], axis=0) return grid.T.reshape(x.size, y.size, 2) grid = meshgrid(np.linspace(-2, 2, 100, dtype=np.float32)) plt.contour(grid[..., 0], grid[..., 1], gm.prob(grid).eval());

Properties

Public properties

object allow_nan_stats get;

object allow_nan_stats_dyn get;

TensorShape batch_shape get;

object batch_shape_dyn get;

object components_distribution get;

object components_distribution_dyn get;

object dtype get;

object dtype_dyn get;

TensorShape event_shape get;

object event_shape_dyn get;

Categorical mixture_distribution get;

object mixture_distribution_dyn get;

string name get;

object name_dyn get;

IDictionary<object, object> parameters get;

object parameters_dyn get;

object PythonObject get;

object reparameterization_type get;

object reparameterization_type_dyn get;

object validate_args get;

object validate_args_dyn get;