TensorPlay
latest (dev)
Copy
View Markdown

Latest development documentation · Updated 2026-10-08

tensorplay.distributions.kl_divergence

tensorplay.distributions.kl_divergence(p: Distribution, q: Distribution) → Tensor[source]

Compute Kullback-Leibler divergence KL(p∥q)KL(p \| q) between two distributions.

KL(p∥q)=∫p(x)log⁡p(x)q(x) dxKL(p \| q) = \int p(x) \log\frac {p(x)} {q(x)} \,dx
Parameters:
Returns:

A batch of KL divergences of shape batch_shape.

Return type:

Tensor

Raises:

NotImplementedError – If the distribution types have not been registered via register_kl().

KL divergence is currently implemented for the following distribution pairs:

On this page

Ask DeepWiki