What initialization loss did Andrej Karpathy expect for a character-level language model?
Andrej Karpathy said the initial loss should be much closer to the uniform-distribution baseline, not something huge like 27. In this setup, he expected a random model to assign about 1/27 probability to each character, which corresponds to a loss of about 3.29. The point was that a sane initialization should start near that value, because the model has no reason to prefer any character at the beginning.
“At initialization, we have no reason to believe any characters to be much more likely than others, and so we'd expect that the probability distribution that comes out initially is a uniform distribution assigning about equal probability to all the 27 characters. So basically, what we'd like is the probability for any character would be roughly 1 over 27. That is the probability we should record, and then the loss is the negative log probability. So let's wrap this in a tensor and then we can take the log of it, and then the negative log probability is the loss we would expect, which is 3.29, much, much lower than 27.”

Key takeaways
- Estimate the random baseline loss for your task.
- If initial loss is wildly off, suspect bad initialization.
- Start training near the expected uniform prediction when no prior exists.
Context
In his 2021 makemore lecture, Karpathy was debugging the character-level MLP and explaining what the loss should look like at initialization. The quote above is taken word for word from the recording's transcript.
In the transcript
…is way too high. In training of neural nets, it is almost always the case that you will have a rough idea for what loss to expect at initialization, and that just depends on the loss function and the problem setup. In this case, I do not expect 27. I expect a much lower number, and we can calculate it together. Basically, at initialization, what we'd like is that there
At initialization, we have no reason to believe any characters to be much more likely than others, and so we'd expect that the probability distribution that comes out initially is a uniform distribution assigning about equal probability to all the 27 characters. So basically, what we'd like is the probability for any character would be roughly 1 over 27. That is the probability we should record, and then the loss is the negative log probability. So let's wrap this in a tensor and then we can take the log of it, and then the negative log probability is the loss we would expect, which is 3.29, much, much lower than 27.
And so what's happening right now is that at initialization, the neural net is creating probability distributions that are all messed up. Some characters are very confident and some characters are very not confident, confident. And then basically what's happening is that the network is very confidently wrong, and that that's what makes it record very high loss. So here's a smaller four-dimensional example of the issue. Let's say we…
Read the full transcript of Building makemore Part 3 lecture, 2021
Topics
What others said about neural networks
More questions about Andrej Karpathy
- What is a neural network, according to Andrej Karpathy?
- What is micrograd and why did Andrej Karpathy build it?
- Why does Andrej Karpathy say neural networks are arranged in layers?
- What does Andrej Karpathy recommend as the default activation function?
- How does Andrej Karpathy use learning rate decay in training neural networks?
- What did Andrej Karpathy say about attention and MLPs in Transformers?
All Andrej Karpathy answers · All Andrej Karpathy recordings
How this answer was made: the quote is checked word for word against the transcript of the recording and confirmed as the speaker's own words; the summary above it was drafted with AI from that transcript and quality-checked. Methodology and corrections.