Cross-entropy loss with masking and label smoothing in NumPy

0
Practice

Implement cross-entropy loss over a batch of logits in NumPy, stable for large values. Add a mask so padded positions do not count, then add label smoothing. Be ready to explain how the loss relates to KL divergence and what smoothing does to the gradients.

OpenAITechnical phone screenMediumLast asked Jul 2026
No answer yet. Write the first one; the best answer gets endorsed.