Machine Learning, Deep Learning, Pytorch, Python, Artificial Neural Network.
as: As cosine lies between - 1 and + 1, loss values are smaller. This aids in computation. Assuming margin to have the default value of 0, if y =1, the loss is (1 - cos(x1, x2)). For y=-1, then the loss will be maximum of 0 and cos(x1, x2). If cos(x1, x2) > 0 loss will be cos(x1, x2) itself (higher