一、Loss functions 中含 F.log_softmax()函数 原因: 由于在计算log_softmax(x)时, 出现log(0)的情况。 解决方法: 给log_softmax的参数x添加一个很小的数: out=F.log_softmax(x+1e-10). 二、loss_function(x)函数参数中出现nan 原因: 网络的生成features x 中含有nan. 解决方法: debug网络模型。