Implement next-token cross-entropy for a batch of logits/targets in numpy with padding mas

Pretraining Objectives & Scaling Laws1 / 4

Chapter 051 / 4

Pretraining Objectives & Scaling Laws

Implement next-token cross-entropy for a batch of logits/targets in numpy with padding mas

Easy

Implement next-token cross-entropy for a batch of logits/targets in numpy with padding masking.

Target interface
next_token_ce(logits, targets, mask=None)

Implement the function/class skeleton in the editor. Any correct approach is accepted.

Hints0 / 2
Reference solution
Your own code stays in the editor.