torch_blue.vi.UniformNormalDivergence

class torch_blue.vi.UniformNormalDivergence

Bases: KullbackLeiblerModule

Kullback-Leibler divergence between a uniform and normal distribution.

Calculates the KL-Divergence between a UniformPrior and a MeanFieldNormalVarDist.

static forward(prior_mean: None, variational_mean: torch.Tensor, variational_log_std: torch.Tensor) torch.Tensor

Calculate the Kullback-Leibler divergence.

All input tensors must have the same shape.

This calculation is affected by _globals._USE_NORM_CONSTANTS, which can be set with use_norm_constants().

Parameters:
  • prior_mean (None) – Always None, exists for technical reasons.

  • variational_mean (Tensor) – Means of the variational distribution.

  • variational_log_std (Tensor) – Standard deviations of the variational distribution.

Returns:

The KL-Divergence of the two distributions.

Return type:

Tensor