I have also met this problem. My mistake is that optimizer.zero_grad() was run after loss.backward(). So optimizer.step() was updated on zero gradients… Hope this may help someone making the same mistake.