I used a Siamese network with contrastive loss as image below, but after few epochs, the loss gave nan value with message
error :'RuntimeError: Function 'PowBackward0' returned nan values in its 0th output.

I have searched this issue, but haven’t find solution yet. I think the problem would be my loss function. Can someone give me some advice? Thanks
loss1107×312 13.2 KB