Asked about Derivatives and the chain rule

Your loss becomes NaN during training. What do you check?

An answer that works

Exploding gradients first: clip them and lower the learning rate. Then check for division by zero or a log of zero in the loss, and for bad input data such as NaNs already present in the batch.

Reading an answer is not being able to give one. The section that teaches this is Derivatives and the chain rule, 5 hours of Calculus for ML.

Learn this properly