The first number: an untrained neuron's accuracy
The tests pass — your neuron works. Now run it on real data and find out the number the rest of the course has to beat.
The panel shows the complete file
neuron.py on the right is now the complete version of your file: holes filled, forward and accuracy written. Compare it with yours. Two things were added:
from fashion import CLASSES, load_fashionat the top —fashion.pyfrom lesson 2;main()at the bottom — what you saw in step 2, only from your code.
test_neuron.py got one test: untrained neurons on 10,000 pictures must land in 3 % – 20 %. That is not "hit 10 %" — you will see why below.
Run it
python neuron.py
one neuron, one image: score=-0.2554 sigmoid=0.4365
probs shape: torch.Size([10000, 10]) row sums to 1.0
first image: predicted Bag, truth Ankle boot
untrained accuracy: 10.2% (chance = 10.0%)
The same four lines you saw in step 2 — now from your code. The last is the number:
10.2 %. This is what a model with no training reaches on its own. Everything above it will be your work.
We learn on ten classes, each about a tenth of the set (942 – 1,027 out of 10,000), so a random guess has 10 % accuracy. You will call this number the baseline: the answer to "did my model learn anything at all".
But "random" is not one number
Change the seed of the random weights and run it ten times:
3.3% 11.4% 8.0% 10.9% 11.3% 9.2% 15.2% 9.0% 8.8% 6.5% | mean 9.4%
The same 10,000 pictures, the same code, only the initial weights differ. The result ranged from 3.3 % to 15.2 %.
So:
10.2 %is not "the right answer", but one of many numbers drawn that day. On your machine, with another PyTorch version orseed, you may get8 %or12 %, and that is just as normal;- if training lifts accuracy from
10 %to10.8 %, that means nothing — chance alone is enough for that. We need jumps.
That is why the test limits are wide (3 % – 20 %): it checks that the model is not wrong-headed and not too good, not "did it hit the same number".
In this course we set
torch.manual_seed(42)everywhere so that your script gives the same number every time. But the same seed on a different machine or PyTorch version may give a different result — the numbers quoted in this course were obtained with PyTorch 2.14, CPU.
One more thing worth seeing
10.2 % is an overall number. Look at what it is made of. Per class (from the step 2 distribution — it guessed almost only bag and boot):
class correct
Bag 30.3 %
Ankle boot 70.6 %
all others 0.0 % – 0.9 %
The two "favourite" answers are right for 30 % and 71 % of their classes' pictures, respectively, and the other eight classes — almost never. But that is not recognition yet: the model says "ankle boot" 5,056 times and is right only 706 times (out of 1,000 real boots). It simply says the same thing almost every time, and sometimes hits.
You will see this again in the next step.