A NaN trap is a debugging or safety mechanism that detects when a computation produces a not-a-number value. In machine learning, NaN values can indicate numerical instability, invalid operations, exploding gradients, or data quality problems.
When one number in your model becomes a NaN
during training, which causes many or all other numbers in your model to
eventually become a NaN.
NaN is an abbreviation for N ot a Number.