Type RelaxedBernoulli
Namespace tensorflow.contrib.distributions
Parent TransformedDistribution
Interfaces IRelaxedBernoulli
RelaxedBernoulli distribution with temperature and logits parameters. The RelaxedBernoulli is a distribution over the unit interval (0,1), which
continuously approximates a Bernoulli. The degree of approximation is
controlled by a temperature: as the temperature goes to 0 the
RelaxedBernoulli becomes discrete with a distribution described by the
`logits` or `probs` parameters, as the temperature goes to infinity the
RelaxedBernoulli becomes the constant distribution that is identically 0.5. The RelaxedBernoulli distribution is a reparameterized continuous
distribution that is the binary special case of the RelaxedOneHotCategorical
distribution (Maddison et al., 2016; Jang et al., 2016). For details on the
binary special case see the appendix of Maddison et al. (2016) where it is
referred to as BinConcrete. If you use this distribution, please cite both
papers. Some care needs to be taken for loss functions that depend on the
log-probability of RelaxedBernoullis, because computing log-probabilities of
the RelaxedBernoulli can suffer from underflow issues. In many case loss
functions such as these are invariant under invertible transformations of
the random variables. The KL divergence, found in the variational autoencoder
loss, is an example. Because RelaxedBernoullis are sampled by a Logistic
random variable followed by a
tf.sigmoid
op, one solution is to treat
the Logistic as the random variable and tf.sigmoid
as downstream. The
KL divergences of two Logistics, which are always followed by a tf.sigmoid
op, is equivalent to evaluating KL divergences of RelaxedBernoulli samples.
See Maddison et al., 2016 for more details where this distribution is called
the BinConcrete. An alternative approach is to evaluate Bernoulli log probability or KL
directly on relaxed samples, as done in Jang et al., 2016. In this case,
guarantees on the loss are usually violated. For instance, using a Bernoulli
KL in a relaxed ELBO is no longer a lower bound on the log marginal
probability of the observation. Thus care and early stopping are important. #### Examples Creates three continuous distributions, which approximate 3 Bernoullis with
probabilities (0.1, 0.5, 0.4). Samples from these distributions will be in
the unit interval (0,1).
Creates three continuous distributions, which approximate 3 Bernoullis with
logits (-2, 2, 0). Samples from these distributions will be in
the unit interval (0,1).
Creates three continuous distributions, whose sigmoid approximate 3 Bernoullis
with logits (-2, 2, 0).
Creates three continuous distributions, which approximate 3 Bernoullis with
logits (-2, 2, 0). Samples from these distributions will be in
the unit interval (0,1). Because the temperature is very low, samples from
these distributions are almost discrete, usually taking values very close to 0
or 1.
Creates three continuous distributions, which approximate 3 Bernoullis with
logits (-2, 2, 0). Samples from these distributions will be in
the unit interval (0,1). Because the temperature is very high, samples from
these distributions are usually close to the (0.5, 0.5, 0.5) vector.
Chris J. Maddison, Andriy Mnih, and Yee Whye Teh. The Concrete Distribution:
A Continuous Relaxation of Discrete Random Variables. 2016. Eric Jang, Shixiang Gu, and Ben Poole. Categorical Reparameterization with
Gumbel-Softmax. 2016.
Show Example
temperature = 0.5 p = [0.1, 0.5, 0.4] dist = RelaxedBernoulli(temperature, probs=p)
Properties
- allow_nan_stats
- allow_nan_stats_dyn
- batch_shape
- batch_shape_dyn
- bijector
- bijector_dyn
- distribution
- distribution_dyn
- dtype
- dtype_dyn
- event_shape
- event_shape_dyn
- logits
- logits_dyn
- name
- name_dyn
- parameters
- parameters_dyn
- probs
- probs_dyn
- PythonObject
- reparameterization_type
- reparameterization_type_dyn
- temperature
- temperature_dyn
- validate_args
- validate_args_dyn
Public properties
object allow_nan_stats get;
object allow_nan_stats_dyn get;
TensorShape batch_shape get;
object batch_shape_dyn get;
object bijector get;
object bijector_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;
object logits get;
Log-odds of `1`.
object logits_dyn get;
Log-odds of `1`.
string name get;
object name_dyn get;
IDictionary<object, object> parameters get;
object parameters_dyn get;
Tensor probs get;
Probability of `1`.
object probs_dyn get;
Probability of `1`.
object PythonObject get;
object reparameterization_type get;
object reparameterization_type_dyn get;
Tensor temperature get;
Distribution parameter for the location.
object temperature_dyn get;
Distribution parameter for the location.