Multi-class Cross-Entropy Loss

Text Generation & NLP Evaluation DS practice problem on Onlearn.

Difficulty: easy.

Topics: Understanding Compute Multi-class Cross-Entropy Loss, Kullback-Leibler Divergence, One-Hot Encoding, Epsilon Clipping, Log-Sum-Exp Trick, Softmax Normalization, Information Theory, Supervised Learning, Numerical Analysis, Probability Theory, Optimization Theory, Loss Function Design, Classification Metrics, Floating Point Arithmetic, Probability Distributions, Gradient-based Learning.

Implement a function that computes the average cross entropy loss for a batch of predictions in a multi class classification task. Your function should take in a batch of predicted probabilities and one hot encoded true labels, then return the average cross entropy loss. Ensure that you handle numerical stability by clipping probabilities by epsilon.