concepts.vision.fm_match.diff3f.diff3f_utils.cosine_similarity#

cosine_similarity(a, b)[source]#

Compute the cosine similarity between two tensors.

Parameters:
  • a (Tensor) – A tensor of shape (N, D).

  • b (Tensor) – A tensor of shape (M, D).

Returns:

A tensor of shape (N, M) containing the cosine similarity between each pair of vectors.

Return type:

Tensor