Neural Network Playground

Build a neural network, train it in your browser with live loss curves, test its predictions, and export the equivalent Keras Python code. No install.

Advertisement

Neural Network Playground: Train a Model in Your Browser

This is a four-step playground for building and training a small neural network without installing anything. Choose a dataset, design the network layer by layer, watch it train with the loss curve updating live, and then test it on new inputs. The training is real: a hand-written forward pass, loss computation, and backpropagation running in a Web Worker so your browser stays responsive. When you are done, it generates the equivalent Keras/Python code so you can rebuild the same architecture in a real framework.

It is a teaching tool, and an honest description matters more than a big claim. The networks are small fully-connected models trained on small datasets in a JavaScript engine. It will not train a large model, it has no GPU acceleration, and the code export produces an architecture definition, not trained weights. What it does give you is the thing that is genuinely hard to get from a textbook: seeing the loss curve respond, in real time, to a change you made to the learning rate.

The Four Steps

  1. Choose Data. Three built-in datasets, plus your own CSV. Titanic Survival is binary classification over mixed numeric and categorical passenger features — the standard first classification problem. Vehicle Classifier is multi-class classification over tabular features. Handwritten Digits is MNIST-style image classification into ten classes, where each pixel becomes an input feature. Uploading a CSV lets you pick the target column and use your own data; it is parsed and processed entirely in your browser.
  2. Design Network. Add hidden layers, set the number of units in each, and choose an activation function per layer. Optimizer, learning rate, batch size, and epoch count are all yours to set. A live diagram redraws as you change the architecture, so you can see what a “16-unit hidden layer” actually is.
  3. Train & Watch. Training runs in a Web Worker with the loss chart and metrics updating per epoch. This is the part worth spending time on — the shape of the loss curve tells you more about what is happening than any single accuracy number.
  4. Test & Ask. Feed the trained network new inputs — draw a digit for the MNIST model, or enter feature values for the tabular ones — and see its prediction with class probabilities.

What Actually Happens During Training

Strip away the vocabulary and a neural network is a stack of matrix multiplications with non-linear functions between them, and training is a search for the numbers in those matrices.

The forward pass. Input values enter as a vector. Each layer multiplies that vector by its weight matrix, adds a bias vector, and applies an activation function elementwise. The result feeds the next layer. The final layer produces the prediction — a sigmoid squashing to a single probability for binary tasks, or a softmax producing a probability distribution over classes for multi-class tasks.

The loss. The prediction is compared to the true label using cross-entropy, which measures how surprised the model was by the correct answer. Confident and right gives a loss near zero; confident and wrong gives a large loss. That single number is what training minimises.

Backpropagation. This is where the learning happens, and it is less mysterious than its reputation. Backprop is the chain rule applied efficiently: starting from the loss, work backwards through the network computing how much each weight contributed to the error. Because each layer’s gradient depends on the layer after it, the calculation naturally runs in reverse — hence the name. The output is a gradient for every weight and bias: the direction in which each should move to reduce the loss.

The update. The optimizer applies those gradients. Plain SGD subtracts the gradient scaled by the learning rate. Adam maintains running averages of the gradient and its square, giving each parameter its own adapted step size, which typically converges faster and is less sensitive to the initial learning rate. Weights are initialised with He initialisation, a scaled random draw that keeps signal magnitudes stable through the layers rather than exploding or vanishing at the start.

Repeat over batches until the epochs run out. That is the whole algorithm.

Learning Rate: the One Setting to Experiment With

The learning rate scales every weight update, and it is the hyperparameter whose effect is most visible in the loss chart. Change it and watch what happens:

  • Too high and the loss oscillates wildly, plateaus at a bad value, or diverges to NaN. The steps overshoot the minimum and bounce across the valley instead of descending it.
  • Too low and the loss falls smoothly but barely — a shallow, nearly flat line. The model is learning correctly and far too slowly to finish in the epochs you allowed.
  • Roughly right and the loss drops steeply for the first few epochs, then flattens into a gentle decline.

Reading that curve is a skill that transfers directly to real training runs, and this is the cheapest possible place to acquire it. A good exercise: train the Titanic model three times at 0.001, 0.01, and 0.5, changing nothing else, and compare the charts.

Activations, and Why the Non-Linearity Matters

The playground offers ReLU, sigmoid, and tanh for hidden layers, with sigmoid or softmax fixed at the output depending on whether the task is binary or multi-class.

The activation function is not decoration. Without it, stacking layers would be pointless — a chain of matrix multiplications with nothing between them collapses algebraically into a single matrix multiplication, meaning a twenty-layer linear network has exactly the expressive power of a one-layer one. The non-linearity is what makes depth buy you anything.

ReLU (output the input if positive, otherwise zero) is the default in modern practice: cheap to compute and its gradient does not shrink for positive inputs. Sigmoid squashes to (0, 1) and tanh to (−1, 1); both saturate at the extremes, where gradients approach zero and learning stalls. That vanishing-gradient problem is precisely why ReLU displaced them in hidden layers. You can reproduce the effect here: build a network several layers deep with sigmoid activations and watch it learn far more slowly than the same network with ReLU.

Exporting to Keras

Once you have an architecture that works, the export panel generates the corresponding Python using keras.Sequential — your hidden layers as Dense layers with their activations, the correct output layer for the task type, your optimizer with the learning rate you chose, the matching loss function, and a model.fit call carrying your epoch count and batch size.

Two honest caveats. The export is code you copy, not a downloadable weights file — running it in Python trains a fresh model from scratch on your own data. And a Keras model trained on the full dataset will not reproduce this playground’s exact numbers, because initialisation is random and the preprocessing here is deliberately simple. What transfers is the architecture and the hyperparameters, which is the part you were actually experimenting to find.

Related Tools

If this leads you toward running larger models, size the hardware with the LLM VRAM calculator, estimate throughput with the inference speed calculator, and price prompts against commercial APIs with the LLM token counter.

Frequently Asked Questions

Does this really train a neural network?

Yes. Forward pass, cross-entropy loss, backpropagation, and optimizer updates all run for real in a Web Worker in your browser. It is a small hand-written engine rather than a wrapper around a framework.

Do I need to install anything?

No. There is nothing to install and no account. Everything runs in the browser, including CSV parsing, so your data never leaves your machine.

What datasets are included?

Titanic survival (binary classification), a vehicle classifier (multi-class), and MNIST-style handwritten digits (ten-class image classification). You can also upload your own CSV and choose the target column.

What is backpropagation, briefly?

The chain rule applied efficiently in reverse through the network, computing how much each weight contributed to the loss so the optimizer knows which direction to move it.

Why is my loss not decreasing?

Most often the learning rate. Too high and the loss oscillates or goes to NaN; too low and it barely moves. Try an order of magnitude in each direction. Also check that your network has at least one hidden layer with enough units to represent the problem.

Which activation should I use?

Start with ReLU for hidden layers. Sigmoid and tanh are included so you can observe the vanishing-gradient effect that made ReLU the default. The output activation is chosen automatically to match the task.

Can I download the trained model?

No. The export produces Keras/Python source code defining the same architecture and hyperparameters, which you copy and run yourself. Trained weights are not exported.

How big a model can I train here?

A small one. It is a CPU-bound JavaScript engine on small datasets, built for understanding rather than scale. For anything substantial, take the exported architecture into a real framework.

What Is the Neural Network Playground

The Neural Network Playground is an interactive way to learn how deep learning actually works - by doing it. Instead of reading about neurons, layers, and backpropagation in the abstract, you train a real neural network on real data, watch every step happen live, and end up with a working model you can question.

Everything runs in your browser on your own hardware. There is nothing to install, no account to create, and no data ever leaves your device - including any CSV files you upload.

How It Works

1. Choose a dataset. Start with one of three built-in datasets: Titanic passenger survival (predict who survived the 1912 sinking), a vehicle classifier (the same problem from our scikit-learn tutorial), or handwritten digit recognition on a subset of the famous MNIST dataset. Or upload any CSV with a category column you want to predict.

2. Design your network. Add hidden layers, choose how many neurons each one has, and pick the activation function, optimizer (Adam or SGD), learning rate, batch size, and number of training epochs. The live diagram shows your architecture as you build it.

3. Train and watch. Hit Start and watch the network learn in real time: the loss curve falls, accuracy climbs, and the connection weights in the network diagram strengthen and change color as patterns are discovered. Pause, fast-forward, or reset and try different settings.

4. Test and ask questions. When training finishes, you get an honest accuracy score on data the network never saw, plus a confusion matrix showing exactly which classes it confuses. Then ask the model your own questions - move sliders to describe a hypothetical Titanic passenger, or draw a digit with your mouse - and watch it predict with confidence scores.

5. Export real code. Any model you build can be exported as equivalent Python code using TensorFlow/Keras - the bridge from playground to production machine learning.

Why Train in the Browser

It is a real neural network. The playground implements the same mathematics used by professional frameworks: forward propagation, cross-entropy loss, backpropagation via the chain rule, and the Adam and SGD optimizers. Nothing is simulated or faked.

Your hardware is enough. The sample datasets train in seconds to under a minute on a typical laptop or phone. Training runs in a background thread, so the page stays responsive while you watch.

Privacy by architecture. Because everything is client-side, uploaded CSV data is processed entirely in your browser memory. You can disconnect from the internet after the page loads and everything still works.

What You Can Learn

  • What neurons, weights, layers, and activation functions actually are
  • How a forward pass turns inputs into predictions
  • What loss measures and why training is "just" error minimization
  • How backpropagation assigns blame to every weight
  • What gradient descent and the learning rate really do (including what happens when the learning rate is too high)
  • Why Adam usually beats plain SGD
  • What epochs and batch sizes mean
  • How to spot overfitting using a held-out test set
  • How the same principles scale from a 2,000-weight toy network to billion-parameter language models

Who This Is For

Students meeting machine learning for the first time, developers who want intuition before diving into TensorFlow or PyTorch, teachers looking for a classroom demonstration, and anyone curious what is actually happening inside the AI systems they use every day.

Frequently Asked Questions

What is a neural network?+

A neural network is a mathematical model made of layers of simple units called neurons. Each neuron multiplies its inputs by adjustable numbers (weights), adds them up, and passes the result through an activation function. Training automatically tunes those weights using examples until the network's predictions match reality. The "knowledge" of a neural network lives entirely in its weights.

Does my data leave my browser?+

No. Training runs 100% on your device using a Web Worker (a background thread in your browser). Sample datasets are downloaded once, and any CSV you upload is parsed and processed entirely in browser memory - nothing is sent to any server. You can disconnect from the internet after loading the page and everything still works.

What is backpropagation?+

Backpropagation is the algorithm that figures out how much each weight in the network contributed to a wrong prediction. After measuring the error, it works backwards through the layers using calculus, computing each weight's share of the blame. Every weight then gets nudged in the direction that reduces the error. This is the core of how all modern neural networks learn.

What is gradient descent and the learning rate?+

Gradient descent is the process of repeatedly nudging weights downhill on the "error landscape" until predictions are good. The learning rate controls how big each nudge is: too small and learning crawls, too large and the network overshoots and never settles. Try setting the learning rate to 0.1 with SGD in the playground to see instability happen live.

What is an epoch?+

One epoch is one complete pass through all the training data. Networks need many epochs because each pass only adjusts the weights a small amount. In the playground you can watch accuracy improve epoch by epoch - early epochs make big gains, later ones fine-tune.

What is overfitting and how do I spot it?+

Overfitting is when a network memorizes its training data instead of learning general patterns. You can spot it in the playground's charts: training accuracy (solid line) keeps climbing while test accuracy (dashed line) flattens or drops. The gap between the two lines is memorization. Try a large network (3 layers of 64 neurons) with 50 epochs on the Titanic data to see it happen.

Which datasets can I train on?+

Three built-in datasets: Titanic survival (712 real passengers - predict who survived), vehicle classification (predict motorcycle/sedan/SUV/truck/bus from specs), and handwritten digits (a 6,000-image subset of MNIST - then draw your own digits). You can also upload any CSV that has a category column to predict, like customer churn or survey results.

Do I need to know how to code?+

No. The entire experience is point-and-click: choose data, design the network with buttons, and train with one click. When you're ready to go deeper, the playground generates the equivalent Python/Keras code for any model you build, and our companion guides walk you through writing real machine learning code.

Related tools

This tool is provided for informational and educational purposes only. All processing happens in your browser — no data is sent to or stored on our servers. While we strive for accuracy, we make no warranties about the completeness or reliability of results.