ExpConcrete¶
-
class
tfsnippet.ExpConcrete(temperature, logits, is_reparameterized=True, check_numerics=None)¶ Bases:
tfsnippet.distributions.wrapper.ZhuSuanDistributionThe class of ExpConcrete distribution from (Maddison, 2016), transformed from
Concreteby taking logarithm.See also
tfsnippet.distributions.Distribution,zhusuan.distributions.Distribution,zhusuan.distributions.ExpConcreteAttributes Summary
batch_shapeGet the batch shape of the samples. dtypeGet the data type of samples. is_continuousWhether or not the distribution is continuous? is_reparameterizedWhether or not the distribution is re-parameterized? logitsThe un-normalized log probabilities. n_categoriesThe number of categories in the distribution. temperatureThe temperature of this concrete distribution. value_shapeGet the value shape of an individual sample. Methods Summary
get_batch_shape()Get the static batch shape of the samples. get_value_shape()Get the static value shape of an individual sample. log_prob(given[, group_ndims, name])Compute the log-densities of x against the distribution. prob(given[, group_ndims, name])Compute the densities of x against the distribution. sample([n_samples, is_reparameterized, …])Generate samples from the distribution. Attributes Documentation
-
batch_shape¶ Get the batch shape of the samples.
Returns: The batch shape as tensor. Return type: tf.Tensor
-
dtype¶ Get the data type of samples.
Returns: Data type of the samples. Return type: tf.DType
-
is_continuous¶ Whether or not the distribution is continuous?
Returns: A boolean indicating whether it is continuous. Return type: bool
-
is_reparameterized¶ Whether or not the distribution is re-parameterized?
The re-parameterization trick is proposed in “Auto-Encoding Variational Bayes” (Kingma, D.P. and Welling), allowing the gradients to be propagated back along the samples. Note that the re-parameterization can be disabled by specifying
is_reparameterized = Falseas an argument ofsample().Returns: A boolean indicating whether it is re-parameterized. Return type: bool
-
logits¶ The un-normalized log probabilities.
-
n_categories¶ The number of categories in the distribution.
-
temperature¶ The temperature of this concrete distribution.
-
value_shape¶ Get the value shape of an individual sample.
Returns: The value shape as tensor. Return type: tf.Tensor
Methods Documentation
-
get_batch_shape()¶ Get the static batch shape of the samples.
Returns: The batch shape. Return type: tf.TensorShape
-
get_value_shape()¶ Get the static value shape of an individual sample.
Returns: The static value shape. Return type: tf.TensorShape
-
log_prob(given, group_ndims=0, name=None)¶ Compute the log-densities of x against the distribution.
Parameters: - given (Tensor) – The samples to be tested.
- group_ndims (int or tf.Tensor) – If specified, the last group_ndims dimensions of the log-densities will be summed up. (default 0)
- name – TensorFlow name scope of the graph nodes. (default “log_prob”).
Returns: The log-densities of given.
Return type: tf.Tensor
-
prob(given, group_ndims=0, name=None)¶ Compute the densities of x against the distribution.
Parameters: - given (Tensor) – The samples to be tested.
- group_ndims (int or tf.Tensor) – If specified, the last group_ndims dimensions of the log-densities will be summed up. (default 0)
- name – TensorFlow name scope of the graph nodes. (default “prob”).
Returns: The densities of given.
Return type: tf.Tensor
-
sample(n_samples=None, is_reparameterized=None, group_ndims=0, compute_density=None, name=None)¶ Generate samples from the distribution.
Parameters: - n_samples (int or tf.Tensor or None) – A 0-D int32 Tensor or None.
How many independent samples to draw from the distribution.
The samples will have shape
[n_samples] + batch_shape + value_shape, orbatch_shape + value_shapeif n_samples isNone. - group_ndims (int or tf.Tensor) – Number of dimensions at the end of
[n_samples] + batch_shapeto be considered as events group. This will effect the behavior oflog_prob()andprob(). (default 0) - is_reparameterized (bool) – If
True, raisesRuntimeErrorif the distribution is not re-parameterized. IfFalse, disable re-parameterization even if the distribution is re-parameterized. (defaultNone, following the setting of distribution) - compute_density (bool) – Whether or not to immediately compute the
log-density for the samples? (default
None, determine by the distribution class itself) - name – TensorFlow name scope of the graph nodes. (default “sample”).
Returns: - The samples as
StochasticTensor.
Return type: tfsnippet.stochastic.StochasticTensor
- n_samples (int or tf.Tensor or None) – A 0-D int32 Tensor or None.
How many independent samples to draw from the distribution.
The samples will have shape
-