-
Notifications
You must be signed in to change notification settings - Fork 394
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add CosineSimilarity #75
Comments
Hi, |
@avinashsai depends on your purpose. preds = [torch.randn(5, 2), torch.randn(10, 2)]
target = [torch.randn(5, 2), torch.randn(10, 2)]
individual_scores = []
for p,t in zip(preds, target):
individual_scores.append(torch.nn.CosineSimilarity()(p, t).mean())
# total score and correct score is different
total_score = torch.mean(torch.stack(individual_scores))
correct_score = torch.nn.CosineSimilarity()(torch.cat(preds, dim=0), torch.cat(target, dim=0)).mean() the global mean does not equal the mean of the score on the individual batches. |
@SkafteNicki Thanks for the clarification. So, this cosine similarity metric will compute between 2 n-dim tensors?? |
It should still be two [N, d] tensors meaning N tensors each with dimension d. |
Hey, I would like to work on this, could you assign it to me? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
🚀 Feature
Add Cosine similarity metric
https://en.wikipedia.org/wiki/Cosine_similarity
Measures the similarity between two feature vectors by calculating the angle between them.
Motivation
Pitch
Alternatives
Additional context
The text was updated successfully, but these errors were encountered: