NumPy allowed · plain Python earns 10 bonus points
θ ← θ − 0.14 · ∂L/∂θ
Calculate negative log-likelihood loss for multi-class classification from predicted softmax probability distributions.
Implement categorical_cross_entropy(probs, targets, eps=1e-12): for each sample i, retrieve the predicted probability p = max(probs[i][targets[i]], eps) for ground truth class index targets[i]. The sample loss is -log(p). Return the average loss across all N samples rounded to 4 decimal places.
categorical_cross_entropy(probs: list[list[float]], targets: list[int], eps: float = 1e-12) -> float