Have you checked the input to torch.log? As mentioned before, negative inputs will give you Nan outputs.


This will also detach your tensors and your model won’t get valid gradients. You should not recreate tensors, but use them directly.


See 2.