Neural Net Playground
A tiny neural network learning to separate red from blue, live in your browser with TensorFlow.js. Watch the colored boundary bend as it trains.
This downloads TensorFlow.js and trains a network on your device, which can be heavy on slower machines.
Click or tap to add a point of the selected class, or use the arrow keys and Enter. The model keeps training on your points.
- Epoch
- 0
- Loss
- –
- Backend
- –
- Live tensors
- 0
Tensor shapes
- xs: [0, 2]
- ys: [0, 1]
- grid: [2500, 2]
- dense_1: kernel [2, 6], bias [6]
- dense_2: kernel [6, 6], bias [6]
- dense_3: kernel [6, 1], bias [1]
A tensor is just a grid of numbers with a shape. Here, the points are a [N, 2] tensor (one row of x, y per point) and their colors are a [N, 1] tensor. The background is one pass of the network over a [2500, 2] tensor of grid coordinates, all at once. Each layer's weights are variables, the one kind of tensor that can change, which is how training happens.
Browser gotcha: tensors live in GPU memory and aren't garbage collected. Per-frame work is wrapped in tf.tidy(), and models are dispose()d on reset or when you leave the page. Watch “Live tensors” stay flat while it trains.