Hmm, that’s interesting. It might be that PyTorch isn’t recording the operations done on it because loss inside bipolar_loss is a python scalar.
Instead of:
loss = 0
try:
loss = torch.tensor(0.0, requires_grad=True)
Let me know if that does something different.