Cosine distance is using max() in denominator

In math cosine distance (or similarity) is calculated as
image
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 :sweat_smile:
Thanks