cupyx.scipy.spatial.distance.cosine#

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

Compute the Cosine distance between two 1-D arrays.

The Cosine distance is defined as

\[d(u, v) = 1 - \frac{u \cdot v}{\|u\|_2 \|v\|_2}\]

where \(x \cdot y\) is the dot product.

Parameters:
  • u (array_like) – Input array of size (N,)

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

Returns:

The Cosine distance between vectors u and v.

Return type:

cosine (double)