cosine_distance

Contents

cosine_distance#

class braintools.metric.cosine_distance(predictions, targets, epsilon=0.0)#

Computes the cosine distance between targets and predictions.

The cosine distance, implemented here, measures the dissimilarity of two vectors as the opposite of cosine similarity: 1 - cos(theta).

References

[Wikipedia, 2021](https://en.wikipedia.org/wiki/Cosine_similarity)

Parameters:
  • predictions (Array | ndarray | bool | number | bool | int | float | complex | Quantity) – The predicted vectors, with shape […, dim].

  • targets (Array | ndarray | bool | number | bool | int | float | complex | Quantity) – Ground truth target vectors, with shape […, dim].

  • epsilon (float) – minimum norm for terms in the denominator of the cosine similarity.

Return type:

Array | ndarray | bool | number | bool | int | float | complex | Quantity

Returns:

cosine distances, with shape […].