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.TensorWrapperSamples or observations of a stochastic variable.
StochasticTensoris a tensor-like object, carrying samples or observations of a random variable, following some distribution of a specificDistributiontype.It mimics the interface of
zhusuan.model.StochasticTensor, except that it does not carry a name, and does not add itself to anyBayesianNetcontext automatically.Attributes Summary
distributionGet the Distributionof thisStochasticTensor.flow_originGet the original stochastic tensor from the base distribution of a tfsnippet.FlowDistribution.group_ndimsGet the number of dimensions to be considered as events group. is_continuousWhether or not this StochasticTensoris continuous?is_reparameterizedWhether or not this StochasticTensoris re-parameterized?n_samplesGet the number of samples taken in Distribution.sample.tensorGet 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
Distributionof 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
Noneif 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
StochasticTensoris continuous?Returns: Equivalent to self.distribution.is_continuous.Return type: bool
-
is_reparameterized¶ Whether or not this
StochasticTensoris 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
-