What is the reason for some nan value when training

As mentioned by @Ehsan1997, it is difficult to identify without looking at code. However, here is a similar thread which might be helpful https://discuss.pytorch.org/t/nan-loss-coming-after-some-time/11568/31