I have the same problem with you, and replace cross_entropy with log_softmax + nll_loss doesn’t work.
It seems to me that nan is more likely to happen when the network is big; when I try the same architecture on a much smaller scale the nan disappear