Weird behavior of CosineSimilarityMetric
when used with tensors of shape [d]
#2240
Labels
CosineSimilarityMetric
when used with tensors of shape [d]
#2240
🐛 Bug?
According to the documentation,
CosineSimilarityMetric
requires tensors of shape[N, d]
, withN
the batch size andd
the dimension of the vectors.Using it with vectors of shape
[d]
does not raise any error, and the call tocompute
behaves weirdly and gives confusing results. I'm not sure whether this is the expected behavior, a bug, or if this usage is simply unintended (and then maybe an error could have been raised).To Reproduce
The obtained result (0.02) is actually the cosine similarity between
[1, 1, 1, 100, 100, 100]
and[100, 100, 100, 1, 1, 1]
. I would have expected to get instead the average between the cosine similarity of[1, 1, 1]
and[100, 100, 100]
and the cosine similarity of[100, 100, 100]
and[1, 1, 1]
, which is 1.If instead we use it as the documentation says, with tensors of shape
[N, d]
, we get different results:Environment:
Additional context
The text was updated successfully, but these errors were encountered: