cupyx.scipy.spatial.distance.kl_divergence#

cupyx.scipy.spatial.distance.kl_divergence(u, v)[source]#

Compute the Kullback-Leibler divergence between two 1-D arrays.

The Kullback-Leibler divergence is defined as

\[KL(U \| V) = \sum_{i} U_i \log{\left(\frac{U_i}{V_i}\right)}\]
Parameters:
  • u (array_like) – Input array of size (N,)

  • v (array_like) – Input array of size (N,)

Returns:

The Kullback-Leibler divergence between vectors u and v.

Return type:

kl_divergence (double)