←

Neural Net Playground

Lab 04 · gradient descent
0Steps
–Loss
0%Right

Tap to place points. Put some orange and some blue, then press Train.

Data

0 points
Tap adds

Network

orange +, blue −
Features
Hidden layers244

Loss

lower is better

Learning

Activation
Regularization
Tap the board to add a point of the chosen colour (Shift-click for the other). Space starts and stops training.
More info

What you're watching

Each dot is orange or blue. The network gets a dot's position (x across, y up, both from −1 to 1) and has to say how likely it is to be orange. The background shows its answer for every spot on the board: orange where it's sure of orange, blue where it's sure of blue, pale where it isn't sure. Dots it gets wrong are crossed out.

Training works the way almost all modern AI learns: gradient descent. For a few dots at a time (the batch) the network measures how wrong it was (the loss), works backwards through its layers to find which way each weight should move to be a little less wrong (backpropagation), and moves every weight a small step that way. The learning rate is the size of that step. Repeat a few thousand times and the boundary bends round the dots.

Things to try

No hidden layers. Take every hidden layer away and the network can only draw a straight line. It can split the two clouds but never the circle, until you give it the x² and y² features.

The spiral. The hardest pattern. Try three layers of six to eight neurons, or add the sin features.

Learning rate. At 0.001 it crawls; at 1 it jumps about and can blow up. Somewhere between is just right.

Overfitting. Turn the noise up and use a big network. It bends round every stray dot. Regularization pulls the weights towards zero, which smooths the boundary.

Your own data. Tap the board to place dots of either colour, or press Clear and draw a pattern from scratch. Your settings and dots are saved in this browser; nothing is sent anywhere.