Deep Learning Playground
Six interactive demos: activation functions, optimizers, convolution filters (CNN), SVM, random forests and Q-learning.
About this playground
This is the next step after the Machine Learning Playground. It shows ideas from deep learning and advanced machine learning. Everything runs in your browser, with nothing to install.
Activation functions and the vanishing gradient
Each neuron applies an activation function. Its derivative decides how much learning signal flows backward. In a deep network the signal is multiplied layer after layer, so a derivative below 1 can shrink it to almost nothing.
Drag the sliders and watch how the gradient changes.
- f(x)
- —
- Derivative f′(x)
- —
- Gradient after n layers ≈ f′(x)ⁿ
- —
Try this
- Pick Sigmoid with 8 layers: its derivative is at most 0.25, so the signal after 8 layers is tiny. This is the vanishing gradient problem.
- Switch to ReLU and keep x above 0: the derivative stays 1, so the signal survives any number of layers.
- Move x below 0 with ReLU: the derivative is 0 (a “dead” neuron). Leaky ReLU keeps a small slope there.
Optimizers: SGD vs Momentum vs Adam
All three race to the minimum (the cross) of a stretched bowl: steep in one direction and gentle in the other. Plain gradient descent zig-zags across the steep direction and crawls along the gentle one. Momentum and Adam fix this in different ways.
Click the map to choose a different starting point.
- Loss: SGD
- —
- Loss: Momentum
- —
- Loss: Adam
- —
- Steps
- —
Try this
- Press Run with the default learning rate: Adam and Momentum reach the cross long before plain SGD.
- Raise the learning rate to about 0.9: SGD starts to zig-zag across the steep direction.
- Click a new starting point and race again to see whether the winner changes.
Convolution filters: how a CNN sees an image
A convolutional neural network slides small filters over an image. Each filter multiplies a 3×3 patch by its weights and adds them up, producing one pixel of a feature map. Different filters pick out different features, such as edges.
Hover over the feature map to see which input patch produced each pixel.
- Feature-map size
- —
- Largest value
- —
Try this
- Choose Square with the Vertical edge filter: the feature map responds only along the left and right sides.
- Switch to the Horizontal edge filter: now the top and bottom edges respond.
- Turn on ReLU and max-pooling: negative responses vanish and the map shrinks, keeping the strongest signals.
Support vector machines: the widest possible margin
An SVM chooses the boundary that leaves the widest gap (margin) between the classes. Only the points closest to the boundary, the support vectors (ringed in gold), decide where it goes. The RBF kernel lets the boundary bend.
Click the map to add points. Dark line = boundary, grey lines = margin.
- Support vectors
- —
- Training accuracy
- —
Try this
- On Separable data with the Linear kernel, only a handful of points (the ringed support vectors) define the boundary.
- On Overlapping data, lower C: the margin widens and tolerates mistakes. Raise C: it fits the training points more strictly.
- Choose Circles: the Linear kernel fails, but the RBF kernel wraps around the inner class.
Random forests: many trees voting together
A random forest trains many decision trees, each on a random resample of the data and with random feature choices, then lets them vote. Single trees are jumpy; the crowd is smoother and usually generalises better.
Solid points are training data; hollow points are test data.
- Forest: training accuracy
- —
- Forest: test accuracy
- —
- Single tree: test accuracy
- —
Try this
- Set trees to 1 and look at the jagged boundary, then slide up to 50: it smooths out as the votes average.
- Raise the depth to 10 so each tree overfits. The forest usually holds up better on test points than one deep tree.
- Press New data a few times and compare forest and single-tree test accuracy. The forest wins more often than not.
Q-learning: an agent learning a maze by trial and error
The agent starts in the gold-framed square and explores. Reaching the star gives +10, falling into a ✕ pit gives −10, and every step costs a little. After each move it updates a table of values Q(state, action). Over many episodes the arrows settle on a good route.
Click a cell to cycle it: empty, wall, pit.
- Episodes
- —
- Last episode reward
- —
- Last episode steps
- —
- Best path length
- —
Try this
- Press Run: early episodes wander, then the arrows point towards the star and the gold path appears.
- Compare γ = 0.5 and γ = 0.99: a higher discount makes the agent care more about the distant star.
- Click cells to add walls or pits and watch the agent learn a new route.
Even more demos?
Explore the ML Algorithms Playground: seven more demos on naive Bayes, ridge and lasso, DBSCAN, hierarchical clustering, gradient boosting, RNN memory and self-attention.
Want the basics first?
The ten foundation demos (gradient descent, k-means, neural networks, overfitting and more) are in the Machine Learning Playground.