The Maths You Actually NeedLesson 46 of 76

Module 5 · Logarithms, information and the shape of a loss

Softmax, its gradient, and the shift it cannot see

In this lesson

  • 9 min read
  • 8 reading sections
  • Knowledge check
  • Lesson 8 of 10 in this chapter

This chapter’s goalCompute a cross-entropy and a KL divergence by hand from two small distributions and say which part of a training loss is irreducible, derive the squared-error and cross-entropy losses from a stated noise assumption, compute a softmax and its gradient for a given set of logits, and explain by the overflow limit of float32 why every library subtracts the maximum before exponentiating.

This chapter’s media

The film explains chapter ideas. The audiobook narrates the complete teaching text.

FormatEnglishहिंदी
Chapter filmNot availableNot available
Full audiobookNot availableNot available

A little at a time

Explore an idea, try it, then check what stays.

Step 1 of 9Free · no account needed
Lesson steps

Turning scores into probabilities

A classifier’s last layer produces one number per class. They can be negative, they need not sum to anything, and they are called logits. Softmax turns them into probabilities:

Text
softmax(z)_i = e^(z_i) / Σ_j e^(z_j)

Compute one. Logits z = (2, 1, 0):

Text
e^2 = 7.389,  e^1 = 2.718,  e^0 = 1.000,  sum = 11.107
p = (7.389, 2.718, 1.000) / 11.107 = (0.665, 0.245, 0.090)

Three properties follow from the exponential. Every output is positive, because e^x is. The outputs sum to 1, by construction. And larger logits give larger probabilities, monotonically.

Your place and first choices stay on this browser. Classroom credit is recorded separately.

Stuck on something?Ask Funke, your AI tutor

How to cite: Addaly (2026) ‘Softmax, its gradient, and the shift it cannot see’, in The Maths You Actually Need. Edited by M. Mun. Addaly. Available at: https://addaly.com/learn/maths-you-need/softmax-and-its-gradient (Accessed: 29 November 2026).