TorchedUp
ProblemsPremium
TorchedUp
Cross-Entropy LossEasy
ProblemsPremium

Cross-Entropy Loss

Implement categorical cross-entropy loss.

Signature: def cross_entropy(y_pred: np.ndarray, y_true: np.ndarray) -> float

Clip predictions to avoid log(0).

Math

Asked at

Python (numpy)0/3 runs today

Test Results

○perfect prediction
○typical
○log stability🔒 Premium
○loss is non-negative
○loss is non-negative (uniform pred)
○zero loss for one-hot match
Advertisement