ContentsThe library

The Mathematics of Cross Entropy

The Simplest Gradient in the Subject

Last timeWhere the Probabilities Come From

Differentiate this loss with respect to the scores and almost everything cancels, leaving the predicted distribution minus the observed one. That is why the two functions are paired.

The previous lesson left the loss in a form with no division and no fraction

inside a logarithm:

J=log⁡ ⁣(∑jezj)−ztJ = \log\!\Big(\sum_{j} e^{z_j}\Big) - z_t

Now differentiate it with respect to one of the scores. This is the calculation

the backward pass performs, and the result is the reason this loss is used.

The one piece of calculus

The second term is easy: ztz_t depends on zkz_k only when kk is the observed

class, so its derivative is 11 in that case and 00 otherwise.

The first term requires the chain rule once. The derivative of a logarithm is

one over its argument, and the derivative of the sum of exponentials with

respect to zkz_k is ezke^{z_k}, since every other term is a constant:

The lesson stops here

7 more paragraphs to go

You have read the opening. The rest of the argument, the problems that check whether it landed, and the lines worth keeping at the end all come with a plan.

The first lesson of every course in the library reads the whole way through, free, so you can see exactly what the rest of them are.

See the planThe contents

This is the reading half

Starting the course gives you your own copy of it. Every idea on every page has problems standing under it, marked with a reason rather than a tick, and any sentence you do not believe can be opened and argued with. None of that can happen on a page nobody owns.

The contents

The rest of this course

  1. 01The Number a Model Is Really Asked For
  2. 02Three Reasons the Logarithm Is Not Optionalopening only
  3. 03The Loss, Written Out in Fullopening only
  4. 04Turning Scores Into a Distributionopening only
  5. 05The Simplest Gradient in the Subjectyou are here
  6. 06The Floor the Loss Cannot Go Belowopening only
  7. 07What a Perplexity of Twelve Meansopening only
  8. 08When a Low Loss Still Lies to Youopening only

Read alongside