torch_blue.vi.KullbackLeiblerModule

class torch_blue.vi.KullbackLeiblerModule

Bases: abc.ABC

Base class for modules calculating the Kullback-Leibler divergence from distribution parameters.

A KullbackLeiblerModule calculates the analytical Kullback-Leibler divergence between a Prior and a VariationalDistribution based on their parameters. They are mainly intended for use with the AnalyticalKullbackLeiblerLoss.

Each subclass must define a forward function that is passed, as positional arguments, the parameters of the Prior in the order specified in its distribution_parameters attribute followed by the parameters of the VariationalDistribution in the order specified in its variational_parameters attribute.