Why this page is a card counter. Every chapter from Chapter 2 on ends by adding a piece to the pipeline, except Chapter 5. That chapter is a building block, and a single neuron never turns up on its own inside a finished language model. So instead of a toy, the chapter closes with a side project to really get to know your neurons: a neuron that cheats at blackjack. This page is the first part of it, the counter on its own with no game around it.
In 1962 a mathematician named Edward Thorp published a book called Beat the Dealer, and it showed that a player could beat blackjack outright. The basic idea is that every card that comes out of the deck changes what's left in it. Deal out a lot of low cards and the deck that remains is rich in tens and aces, which is good for the player. Deal out a lot of high cards and the rest of the deck is poor, which is good for the house. So you keep a number in your head that tracks which way the deck has gone, and when the number says the deck is rich, bet more. The count that took over came a year later, from an engineer named Harvey Dubner: the Hi-Lo count. It's just a weighted sum, the same simple multiply-and-add that the chapter's neurons run.
Here are the weights, which are pretty much the whole system: 2, 3, 4, 5 and 6 count +1; 7, 8 and 9 count 0; 10, jack, queen, king and ace count −1. You add the weights up as the cards appear, and the total is called the running count. The count has the same shape as the chapter's face detector: it reads fifty-two inputs, one per card, each one 0 because you haven't seen it or 1 because you have, multiplies each input by its weight, and adds up the results. One part of the neuron is missing on purpose. There's no ReLU, because a negative count is real information (it says the deck that's left is poor, so bet small), and there's no bias, because a fresh deck is neutral and a count that starts at zero already says so.
Deal the whole deck and the running count must finish at 0, because the twenty cards worth +1 and the twenty worth −1 cancel, and the twelve worth 0 never mattered.
Every card carries one of these three weights. Each click multiplies the card that came out by its weight and adds the result to the running count.