huawei-noah / Efficient-Computing

Efficient computing methods developed by Huawei Noah's Ark Lab
1.2k stars 210 forks source link

梯度回传时出现nan, #143

Open li1changxing opened 4 months ago

li1changxing commented 4 months ago

https://github.com/huawei-noah/Efficient-Computing/blob/master/Data-Efficient-Model-Compression/DAFL/DAFL-train.py#L179

loss_information_entropy = (softmax_o_T * torch.log10(softmax_o_T)).sum()

RuntimeError: Function 'XlogyBackward0' returned nan values in its 1th output.

这里是不是会出现当softmax后概率过小或者为0的情况时,会出现nan的情况,当时你遇到过吗,如果遇到过,当时是怎么解决这个问题的。