Thank you for your reply！It is really helpful and gives me a deeper understanding of the details of “F.log_softmax”. I print the last linear layer’s parameters when error occurs, and the parameters are ‘nan’. It may have overflowed when executing ‘F.softmax’ or ‘log’, I will add ‘assert’ to debug the code.