By Vladimir DolgopolovMachine learning2 min read
What can 105 numbers learn?
A small model shows clearly what training changes.
Take a point on a plane, with coordinates x and y, and ask a small neural network which of two groups it belongs to. That is the whole task in the lab’s learning experiment.
The network never sees the rule that draws the groups, only examples. Training adjusts a set of numbers until its answers fit those examples.
What are the 105 numbers?
The network has two inputs, two hidden layers of eight neurons, and one output. Each connection has a weight. Each neuron after the input has a bias. Add them up:
A neuron multiplies its inputs by their weights, adds the results and its bias, then passes that sum through an activation function. The hidden layers use . The final layer uses , producing a value between zero and one.Of the 105, 88 are weights and 17 are biases.
tanh
Squashes any sum into a value between −1 and 1. Because it bends, stacked layers can draw curved boundaries instead of straight lines.
sigmoid
Squashes any sum into a value between 0 and 1, so the output can be read as a probability. Formula: 1 / (1 + exp(−x)).
That value is the model’s estimate that a point is Class A. The line on the plot is the 50% boundary, where the prediction flips.
Learning means changing the numbers
The model starts from random weights, so its first boundary is arbitrary. At each training step it predicts every example and measures the error with .The weights come from a fixed seed, so every reset draws the same first boundary.
Binary cross-entropy
The loss for yes-or-no answers. A Class A point costs −log p, a Class B point −log(1 − p), averaged over all points. Confident mistakes cost the most.
Backpropagation calculates how each parameter contributes to that error. The uses those gradients to update the parameters, and the step repeats.
Adam
An optimizer that gives every parameter its own step size, using running averages of its recent gradients and of their squares. Here: learning rate 0.02, β₁ 0.9, β₂ 0.999.
Choose Rings and press Train. Once the boundary has formed, add a Class B point near the centre and train again. The boundary bends to fit it.
Try the experimentWhat training fit doesn’t tell you
The score shown is training fit: the share of training points classified correctly. A high score does not mean the model will do well on new points. It can learn noise, or bend its boundary around one unusual example.A run stops after 1,600 steps. On the default Rings points, that is enough for 100% training fit.
Explore further: TensorFlow Playground. Implementation: the experiment’s source.