VariationalInference

class tfsnippet.VariationalInference(log_joint, latent_log_probs, axis=None)

Bases: object

Class for variational inference.

Attributes Summary

axis Get the axis or axes to be considered as the sampling dimensions of latent variables.
evaluation Get the factory for evaluation outputs.
latent_log_prob Get the summed log-density of latent variables.
latent_log_probs Get the log-densities of latent variables.
log_joint Get the log-joint of the model.
lower_bound Get the factory for variational lower-bounds.
training Get the factory for training objectives.

Methods Summary

zs_elbo() Create a zhusuan.variational.EvidenceLowerBoundObjective, with pre-computed log-joint.
zs_importance_weighted_objective() Create a zhusuan.variational.ImportanceWeightedObjective, with pre-computed log-joint.
zs_klpq() Create a zhusuan.variational.InclusiveKLObjective, with pre-computed log-joint.
zs_objective(func, **kwargs) Create a zhusuan.variational.VariationalObjective with pre-computed log-joint, by specified algorithm.

Attributes Documentation

axis

Get the axis or axes to be considered as the sampling dimensions of latent variables.

evaluation

Get the factory for evaluation outputs.

Returns:The factory for evaluation outputs.
Return type:VariationalEvaluation
latent_log_prob

Get the summed log-density of latent variables.

Returns:The summed log-density of latent variables.
Return type:tf.Tensor
latent_log_probs

Get the log-densities of latent variables.

Returns:The log-densities of latent variables.
Return type:tuple[tf.Tensor]
log_joint

Get the log-joint of the model.

Returns:The log-joint of the model.
Return type:tf.Tensor
lower_bound

Get the factory for variational lower-bounds.

Returns:The factory for variational lower-bounds.
Return type:VariationalLowerBounds
training

Get the factory for training objectives.

Returns:The factory for training objectives.
Return type:VariationalTrainingObjectives

Methods Documentation

zs_elbo()

Create a zhusuan.variational.EvidenceLowerBoundObjective, with pre-computed log-joint.

Returns:
The constructed
per-data ELBO objective.
Return type:zhusuan.variational.EvidenceLowerBoundObjective
zs_importance_weighted_objective()

Create a zhusuan.variational.ImportanceWeightedObjective, with pre-computed log-joint.

Returns:
The constructed
per-data importance weighted objective.
Return type:zhusuan.variational.ImportanceWeightedObjective
zs_klpq()

Create a zhusuan.variational.InclusiveKLObjective, with pre-computed log-joint.

Returns:
The constructed
per-data inclusive KL objective.
Return type:zhusuan.variational.InclusiveKLObjective
zs_objective(func, **kwargs)

Create a zhusuan.variational.VariationalObjective with pre-computed log-joint, by specified algorithm.

Parameters:
  • func – The variational algorithm from ZhuSuan. Supported functions are: 1. zhusuan.variational.elbo() 2. zhusuan.variational.importance_weighted_objective() 3. zhusuan.variational.klpq()
  • **kwargs – Named arguments passed to func.
Returns:

The constructed

per-data variational objective.

Return type:

zhusuan.variational.VariationalObjective