StochasticTensor¶
-
class
tfsnippet.
StochasticTensor
(distribution, tensor, n_samples=None, group_ndims=0, is_reparameterized=None, flow_origin=None, log_prob=None)¶ Bases:
tfsnippet.utils.tensor_wrapper.TensorWrapper
Samples or observations of a stochastic variable.
StochasticTensor
is a tensor-like object, carrying samples or observations of a random variable, following some distribution of a specificDistribution
type.It mimics the interface of
zhusuan.model.StochasticTensor
, except that it does not carry a name, and does not add itself to anyBayesianNet
context automatically.Attributes Summary
distribution
Get the Distribution
of thisStochasticTensor
.flow_origin
Get the original stochastic tensor from the base distribution of a tfsnippet.FlowDistribution
.group_ndims
Get the number of dimensions to be considered as events group. is_continuous
Whether or not this StochasticTensor
is continuous?is_reparameterized
Whether or not this StochasticTensor
is re-parameterized?n_samples
Get the number of samples taken in Distribution.sample
.tensor
Get the samples or observations tensor. Methods Summary
log_prob
([group_ndims, name])Compute the log-densities of this StochasticTensor
.prob
([group_ndims, name])Compute the densities of this StochasticTensor
.Attributes Documentation
-
distribution
¶ Get the
Distribution
of thisStochasticTensor
.Returns: The distribution instance. Return type: Distribution
-
flow_origin
¶ Get the original stochastic tensor from the base distribution of a
tfsnippet.FlowDistribution
.Returns: - The original stochastic tensor,
- or
None
if there is no original stochastic tensor.
Return type: StochasticTensor or None
-
group_ndims
¶ Get the number of dimensions to be considered as events group.
Returns: The configured group_ndims. Return type: int or tf.Tensor
-
is_continuous
¶ Whether or not this
StochasticTensor
is continuous?Returns: Equivalent to self.distribution.is_continuous
.Return type: bool
-
is_reparameterized
¶ Whether or not this
StochasticTensor
is re-parameterized?Returns: A boolean indicating whether it is re-parameterized. Return type: bool
-
n_samples
¶ Get the number of samples taken in
Distribution.sample
.Returns: The number of samples. Return type: int or tf.Tensor or None
-
tensor
¶ Get the samples or observations tensor.
Returns: The tensor specified at construction. Return type: tf.Tensor
Methods Documentation
-
log_prob
(group_ndims=None, name=None)¶ Compute the log-densities of this
StochasticTensor
.Parameters: - group_ndims (int or tf.Tensor) – If specified, overriding the configured group_ndims.
- name – TensorFlow name scope of the graph nodes.
Returns: The log-densities.
Return type: tf.Tensor
-
prob
(group_ndims=None, name=None)¶ Compute the densities of this
StochasticTensor
.Parameters: - group_ndims (int or tf.Tensor) – If specified, overriding the configured group_ndims.
- name – TensorFlow name scope of the graph nodes.
Returns: The densities.
Return type: tf.Tensor
-