In math cosine distance (or similarity) is calculated as
But according to pytorch documentation, it’s calulated as
https://pytorch.org/docs/master/nn.html?highlight=cosine#torch.nn.CosineSimilarity
Can someone explain the difference, please?
In math cosine distance (or similarity) is calculated as
But according to pytorch documentation, it’s calulated as
https://pytorch.org/docs/master/nn.html?highlight=cosine#torch.nn.CosineSimilarity
Can someone explain the difference, please?
The max
operation just prevents dividing by zero or a very small number smaller than eps
.
Besides that both formulas are equal.
oops, I didn’t see the dot sign
Thanks