Your training might have diverged, the loss increased, and eventually a NaN was returned due to e.g. overflow. Alternatively, you are using some operations such as divisions, which could eventually divide by 0. and create the invalid outputs. This is my best guess without more information about the model and training.