Back
Interactive Laboratory

Neural Network Playground

Construct a classification dataset, adjust model hyperparameters, and observe a neural network deduce a decision boundary in your browser.

Model

2 → H → 1

Method

Backprop

Task

Binary

Playground Environment

Interactive Neural Network Canvas

Read Theory
Neural Playground: Click to add data points
Random Initial Weights
Class AClass BLeft Click: Add • Right Click: Remove
Step 1

Inject Data

Adjust points on the canvas. Current Map: Linear

Topology: 2 → 4 → 1
Status: The linear dataset should converge quickly and produce a nearly straight separating boundary.
Total Samples
12
Class A
6
Class B
6
Step 2

Train Model

Set capabilities, then run backpropagation to warp the canvas space.

Engine Ready

Controls how much the decision boundary can bend.

How fast the mathematical gradient is traversed.

Stops extreme overfitting by limiting weight sizes.

Epoch
0
Training cycles
Loss
0.000
Goal: Approach 0.0
Accuracy
0%
Correctly split dots
‖W‖
0.00
Overfitting penalty size

Core Mathematics

Architecture

This relies on a shallow multi-layer perceptron (MLP) with a structural path of 2 → 4 → 1. (x, y) coordinates map from $[-1, 1]$. The hidden layer utilizes tanh activation to warp the manifold; followed by sigmoid squashing to resolve final class probability.

Forward Pass

Mathematical flow for every pixel on screen:

z = W₁·x + b₁
a = tanh(z)
ŷ = σ(w₂ᵀ·a + b₂)
Loss & Gradient Descent

Training strictly minimizes binary cross-entropy loss iteratively:

L = −(1/n) Σ [yᵢ log(ŷᵢ) + (1−yᵢ) log(1−ŷᵢ)]

We calculate derivatives entirely client-side via backpropagation, updating the weights constantly:

θ ← θ − η·(∇L + λ·θ)

Operating Notes

01

Establish Data Points

Plot samples on the canvas and alternate between Class A and Class B. Keep at least one point from each class.

02

Select a Preset

Load Linear, XOR, or Rings to inspect how geometry changes the boundary the network must learn.

03

Configure and Train

Adjust hidden units, learning rate, and regularisation, then run training to observe the fitted surface.

04

Analyse the Output

Read loss, accuracy, and weight magnitude together. The contour marks the region where the model is uncertain.

Architecture

The simulator runs a single-hidden-layer perceptron. Inputs are normalized canvas coordinates, hidden units use tanh, and the output sigmoid represents the probability of Class B.

textHidden:mathbfz=mathbfW1mathbfx+mathbfb1,quadmathbfa=tanh(mathbfz)\\text{Hidden: } \\mathbf{z} = \\mathbf{W}_1\\mathbf{x} + \\mathbf{b}_1, \\quad \\mathbf{a} = \\tanh(\\mathbf{z}) textOutput:haty=sigma(mathbfw2Tmathbfa+b2)\\text{Output: } \\hat{y} = \\sigma(\\mathbf{w}_2^T\\mathbf{a} + b_2)

Training Loop

Each training step performs full-batch gradient descent against binary cross-entropy and adds L2 regularisation to discourage unnecessarily large weights.

mathcalL=frac1nsumi=1nleft[yilog(hatyi)+(1yi)log(1hatyi)right]+fraclambda2nmathbfw22\\mathcal{L} = -\\frac{1}{n} \\sum_{i=1}^n \\left[ y_i \\log(\\hat{y}_i) + (1 - y_i) \\log(1 - \\hat{y}_i) \\right] + \\frac{\\lambda}{2n} \\|\\mathbf{w}\\|_2^2