Skip to content
All apps

Basin of Attraction

About this app

Drag target points across a plane while a neural network colours the basins of attraction live. The "network size" slider: too few neurons → coarse, wrong basins — the "enough neurons?" question to touch.

Basins and network size

Place a few target points on a plane and assign every location to its nearest point, and you get basins with straight boundaries, a Voronoi diagram. A neural network is meant to learn this assignment: it takes the coordinates of a location and outputs a probability for each class through a softmax. How precisely it hits the boundaries depends on its size. With too few neurons in the hidden layer it cannot represent the shape of the basins; with enough neurons the learned and the true boundaries line up.

What the app shows

Two to five glowing target points sit on a plane, each standing for a class. A small network of the form f(x) = softmax(W₂ tanh(W₁x + b₁) + b₂) learns live and colours the plane by the class that wins at each location. A confidence relief lowers the plane at uncertain boundaries. The values panel shows neurons, parameters, training steps and the share of locations where the learned basin matches the true one.

Things to try

Drag the target points across the plane and watch the network relearn. Set the network size to 1 or 2 neurons: the basins turn coarse and wrong, and the match rate drops. Raise the slider step by step up to 48 and find the point where the boundaries fit. With more target points the network needs more neurons. “Retrain” starts again with fresh weights.

Frequently asked questions

How many neurons does a neural network need?
It depends on how complex the function is that the network has to learn. Too few neurons cannot represent the shape, and the network underfits. Too many raise the computing cost and the risk of overfitting. In practice you try different sizes and check the result on validation data.
What is a Voronoi diagram?
A Voronoi diagram divides a plane into regions so that each region contains all locations closest to one particular point. The boundaries between two regions are segments of the perpendicular bisector between the two points. Such partitions appear in geometry, geography and classification.
What does “basin of attraction” mean?
In dynamics, a basin of attraction is the set of all starting points that move towards the same target. This app uses the term figuratively: the basin of a class is the region of the plane that the network assigns to that class.
What can I try in this app?
You move two to five target points, set the number of neurons between 1 and 48 and see how well the learned basins match the true ones. The app tells you whether the neurons are enough.

Subject: Neural networks

More from Neural networks

A VisuApp by heyprof: interactive, free in your browser, no sign-up. What is a VisuApp? · All apps