Hi, I rewrote the loss and now it’s computed as:
    loss = pred.mm(pred.T) - (label.view(-1,1) == label.view(1,-1)).to(dtype=torch.float32)
    loss = (loss**2).sum()
    loss = loss / (label.size(0)**2 +1.0)
    
    return loss

where pred is computed as:
pred = 1.0 / (1.0 + (-pred).exp())

however, another error occured:
RuntimeError: Function 'ExpBackward' returned nan values in its 0th output.

which is traced to the ‘.exp’ operation.
The loss value is 0.980656 when this happened. Can you figure this out?