osl_dynamics.inference.ops.categorical_kl_divergence#
- osl_dynamics.inference.ops.categorical_kl_divergence(inference_logits, model_logits, reduction)#
KL divergence between the posterior and prior of a sequence of categorical 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_logitstf.Tensor
Posterior logits. Shape is (batch_size, sequence_length, n_states).
- model_logitstf.Tensor
Prior logits. Shape is (batch_size, sequence_length, n_states).
- reductionstr
'sum'sums over time,'mean'averages over time.
- Returns:
- kltf.Tensor
KL divergence reduced over time and averaged over sequences.