Your first neuron.
Every neural network starts somewhere. Meet its smallest building block—and teach it to make a better prediction.
Can a number learn a pattern?
A shop sells identical items. The total price depends on how many you buy. Our model makes a guess using two numbers: a weight and a bias.
What happens if we increase the weight?
Keep the input at 2 and the bias at 0. Before touching the sliders, take a guess.
Make the neuron your own.
Open standaloneMove the weight and bias sliders. Then try One step to see how training changes them, or Watch it learn to run 150 small updates.
Bias shifts it up or down.
The dots are example prices. The line is your model. Dashed gaps show its errors. All calculations run in your browser.
A small calculation with a big job
Imagine a shop where every item costs the same amount, plus a fixed packing fee. A simple model can estimate the total price from the number of items.
It needs just two adjustable numbers: a weight for the price per item, and a bias for the fixed fee. Together, they form our first neuron.
This is a made-up price example designed to make every calculation visible. Real prices depend on many more things.
What is actually learning?
In the playground, the four example prices are 5, 8, 11, and 14 credits for one through four items. The model begins with a poor guess: a weight of 1 and a bias of 0.
Training compares its predictions with the examples. It measures the errors, calculates how the weight and bias affect those errors, and adjusts both a little. Repeating this process is gradient descent.
- Weight changes the slope. A larger weight adds more to the prediction for each extra item.
- Bias changes the starting point. It raises or lowers every prediction by the same amount.
- Loss measures the mistakes. Here, we average the squared errors across all four examples. Large mistakes count more.
One neuron is a starting point
This lesson uses a neuron with a linear output: its graph is a straight line. Later, we’ll add nonlinear activation functions and connect neurons into layers, so the network can represent more complicated patterns.
A perfect fit to these four examples only tells us the model fits this tiny training set. We still need new examples to check generalization.
Go deeper: see one learning update
For each example, calculate prediction minus target. The weight gradient averages twice that error times the input; the bias gradient averages twice the error. Both updates use the same old parameters.
At weight 1 and bias 0, the gradients are −40 and −14. One step gives weight 1.8 and bias 0.28. The average squared error falls from 54 to 24.0784.
A new prediction. Same idea.
Set aside the playground values. A model has weight = 3 and bias = 2. What will it predict for 3 items?
You’ve met the smallest building block.
A neuron combines inputs with a weight and a bias. Learning adjusts those parameters to reduce error. A network connects many of these computations.
Loss functions & gradient descent
Why some updates improve a model—and others go too far.