How to compute the cosine similarity between two cryptensors?
See original GitHub issueFeature
I wonder how to compute the cosine similarity between two cryptensors. Could anyone give me some suggestions?
For example,
import crypten
x = torch.tensor([1, 2, 3], dtype = torch.float)
x_enc = crypten.cryptensor(x)
y_enc = crypten.cryptensor([2.0, 3.0, 4.0])
Alternatives
Additional context
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Cosine Similarity - LearnDataSci
Cosine similarity is a metric used to measure the similarity of two vectors. ... we have two vectors, A and B, the similarity...
Read more >Cosine Similarity - GeeksforGeeks
Consider an example to find the similarity between two vectors – 'x' and 'y', using Cosine Similarity. The 'x' vector has values, x...
Read more >Cosine Similarity – Understanding the math and how it ...
Cosine similarity is a metric used to measure how similar the documents are irrespective of their size. It is the cosine of the...
Read more >How to compute the Cosine Similarity between two tensors in ...
To compute the cosine similarity between two tensors, we use the CosineSimilarity() function provided by the torch.nn module.
Read more >How to calculate the Cosine similarity between two tensors?
With the latest TF API, this can be computed by calling tf.losses.cosine_distance . Example: import tensorflow as tf import numpy as np x...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@knottb Note that PyTorch implementation does something to prevent division by zero. We may need something similar if we were to add cosine similarity in CrypTen.
Hi, what if the data is beyond the valid range [0.05,200]? Is there any way to compute them correctly now?