Neural Network Playground
Build a small neural network, press Play and watch it learn to separate the dots. Change the layers, neurons, activation and learning rate, then run the same network as Python code. Or paste your own table, train on it and ask the network for answers.
How to use it
- 1Choose the dataPick a problem: a shape, a real problem (rain, spam, taxi fare...) or your own table.
- 2Train the modelPress Play. The network trains and the loss goes down.
- 3Try a predictionTry a prediction: type new values under Output and read its answer.
- 4Experiment and compareChange the layers, neurons or learning rate and compare, then run the Python code.
Pick a real problem to train on it at once, or keep a shape on the left to see how the network bends its boundary.
Press ▶ to start training. It stops by itself when the model stops improving.
Data
One group sits in the middle and the other forms a ring around it. No straight line can split them, so the model has to learn a closed curve.
Network
A neuron is the smallest unit of the network. It takes its inputs, multiplies each by a weight, adds them up and passes the total through the activation function to give one number. Each circle in the diagram is a neuron. A layer is a column of neurons that all read the outputs of the layer before. Hidden layers sit between the inputs and the output. More layers let the model learn more complex boundaries, but training takes longer.Output
The loss curve appears once training starts.
Try a prediction
Type new input values. The answer changes as the network learns.
The map is drawn when exactly 2 inputs are on. Turn inputs on or off in the network, or use Try a prediction below.
Enter your own problem
Paste a table with one row per example: the input columns first, the answer in the last column. Two labels (like yes / no) teach the network to classify; numbers (like prices) teach it to predict a value.
Not sure what to paste? Pick a real problem above the network: its table appears here and you can edit it.
This network in Python
The code follows your settings: the same data, features, layers, activation and learning rate. Run it to train the network in Python, or ask the AI to explain it.
Free to try without an account. Sign in for more AI help.
Ordinary programming vs a neural network
Same problem: from hours studied and hours slept, will a student pass? The two approaches solve it on completely different principles.
1Ordinary programming: you write the rule
The programmer has to understand the problem, work out a formula or a set of if/else conditions and write it as code. The computer does exactly what was written. It is clear and easy to check, but it only works when you know the rule.
# Ordinary programming: the rule is written by hand
def predict(hours_studied, hours_slept):
if 0.7 * hours_studied + 0.6 * hours_slept > 7.6:
return "yes"
return "no"
print(predict(8, 7))
print(predict(3, 6))
2Neural network: the computer finds the rule
You do not write the rule. You give the model many examples with the right answers, and during training it adjusts its weights until its predictions match them: it finds the rule itself. This suits problems whose rule is too complex to write down, such as recognising images, speech or spam.
from sklearn.neural_network import MLPClassifier
# Examples: [hours_studied, hours_slept] and the real answer
X = [[6.9, 7.9], [0.9, 7], [9.1, 5.1], [6.6, 4.1], [9, 5.4], [2.5, 4.1], [2.7, 4.6], [2.5, 4.4], [4.1, 8.9], [2.2, 8.3], [5.1, 8], [6.4, 6.9], [6.1, 4], [3.5, 8.4], [8.3, 5.4], [3.5, 7.8], [0.8, 4.4], [2.5, 8.7], [9.5, 5.4], [8.5, 6.9], [5.4, 4.5], [1.6, 5.3], [0.8, 5.6], [4.1, 4.5]]
y = ["yes", "no", "yes", "no", "yes", "no", "no", "no", "no", "no", "yes", "yes", "no", "yes", "yes", "no", "no", "no", "yes", "yes", "no", "no", "no", "no"]
# The network finds the rule from the examples
model = MLPClassifier(hidden_layer_sizes=(4, 2), max_iter=3000, random_state=0)
model.fit(X, y)
print(model.predict([[8, 7], [3, 6]]))
The tool at the top of this page does the second thing: you watch the network find the rule in the data.
Try these experiments
Each one loads a setup. Press Play and watch what happens, then change one thing at a time.
How a neural network learns
Every epoch on this page runs the same three steps over the training dots.
Learn the ideas behind it
Short lessons with runnable Python for each idea you see on this page.
- Neurons and Activation Functions in PythonBuild an artificial neuron in plain Python: a weighted sum of inputs plus a bias, passed through sigmoid or ReLU.
- Forward Propagation and Loss Functions in PythonPass inputs through a small neural network layer by layer, then measure the error with squared error and cross-entropy.
- Gradient Descent and Backpropagation in PythonTrain a neuron with gradient descent: use the chain rule to find how each weight affects the loss, then step downhill.
- Neural Network Optimizers: SGD, Momentum and Adam in PythonCompare plain gradient descent, momentum and Adam by minimizing the same function step by step.
- Data Preparation for Machine Learning in PythonScale features with min-max normalization and z-score standardization, and multiply matrices by hand.
- Classification Basics: Softmax and k-Nearest Neighbors in PythonTurn scores into class probabilities with softmax, score them with cross-entropy and classify points with k-nearest neighbors.
- Linear and Logistic Regression in PythonFit a straight line with least squares, then turn a score into a probability with logistic regression.
- Practise it in Python: the Neural networks learning pathLessons and coding challenges, from one neuron to a full network.
- Neural networks quizCheck what you learned with short questions.
Frequently asked questions
What is a neural network playground?
A page where you build a small neural network and watch it train live, with nothing to install. Each dot is a training example, the background colour is what the network predicts for that spot, and the loss chart shows how wrong it still is.
How is this different from TensorFlow Playground?
The idea is the same: a small network trained live in the browser. This playground also writes your network as NumPy or PyTorch code that you can run and change in the Python editor, and the AI can explain the code line by line.
Why does my loss stop going down?
Usually the learning rate is too high (the loss jumps around) or too low (it barely moves), or the network is too small for the pattern. Try more neurons, another layer, or features such as X1 squared for the circle.
Do I need a GPU or Python installed?
No. The playground trains in your browser, and the Python code runs on our servers when you press Run this code.
What does Show a sharp boundary do?
It colours each spot fully blue or fully orange instead of showing how sure the network is, so you see the exact decision boundary.
Can I train it on my own data?
Yes. Paste a table (CSV, or copy cells from Excel or Google Sheets): the input columns first, the answer in the last column. Two labels such as yes / no make a classifier; numbers such as prices make a regression. Then type new inputs under Try a prediction to get its answer, and the Python code includes your data.
Related lessons
- Neurons and Activation Functions in PythonBuild an artificial neuron in plain Python: a weighted sum of inputs plus a bias, passed through sigmoid or ReLU.
- Gradient Descent and Backpropagation in PythonTrain a neuron with gradient descent: use the chain rule to find how each weight affects the loss, then step downhill.
- Forward Propagation and Loss Functions in PythonPass inputs through a small neural network layer by layer, then measure the error with squared error and cross-entropy.