Numerically Stable Softmax

easy
Unit 1 · Activations0/3 to milestone

Implement softmax(z, axis=-1). The naive version overflows for logits like 1000. Subtract the maximum along axis first: softmax is unchanged by adding a constant to every logit.

Must work for any array shape and any axis.

#activations#numerics2 visible + 1 hidden tests
solution.py · Python 3.13
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Numerically Stable Softmax · TechGradify