jbschlosser:

Expanding on @Versus’s answer, the loss function form is nn.CosineEmbeddingLoss.
nn.TripletMarginLoss may be helpful to you as well.


Sorry, I don’t  know how to set the y label of nn.CosineEmbeddingLoss in my case. Is it -1?