osl_dynamics.inference.ops.normal_kl_divergence#
- osl_dynamics.inference.ops.normal_kl_divergence(inference_mu, inference_sigma, model_mu, model_sigma, *, epsilon, reduction)#
KL divergence between the posterior and prior of a sequence of normal distributions.
The model network predicts one time step into the future, so the prior at time
tis compared with the posterior at timet + 1.- Parameters:
- inference_mutf.Tensor
Posterior means. Shape is (batch_size, sequence_length, n_modes).
- inference_sigmatf.Tensor
Posterior standard deviations.
- model_mutf.Tensor
Prior means. Shape is (batch_size, sequence_length, n_modes).
- model_sigmatf.Tensor
Prior standard deviations.
- epsilonfloat
Value added to the standard deviations.
- reductionstr
'sum'sums over time,'mean'averages over time.
- Returns:
- kltf.Tensor
KL divergence summed over modes, reduced over time and averaged over sequences.