I defined a new loss module and used it to train my own model. However, the first batch’s loss always get inf or nan,  which leads to fail.
I try to print the loss item info as follows:
loss item: inf
loss item: 7.118189334869385
…
loss item: 7.123733997344971
what  may it happpens?  I test the loss module and it works with some synthesis data. And the module is implemented with torch functions as well.
Could someone occcur this kind of  problem?