Neural Network Visualizer

Explore the space between digits.

A small network squeezes every handwritten digit into just two numbers, and learns to draw a digit from any two numbers. So every point on this map is a digit: drag the point and watch one digit turn into another.

Map

Drag the point, tap anywhere on the map, or focus the point and use the arrow keys (hold Shift for bigger steps).

Each dot is a test digit the network never saw in training, placed at its two numbers. Digits that look alike land near each other.Each tile is the digit the decoder draws at that spot. Every point is a digit, and neighbors look alike.

At the point

z1 –z2 –

Looks like ?

as read by the network on the Digits page

Morph

Slide the point from one place to another and watch the digit change on the way.

    Every step is drawn fresh from its own two numbers, not two pictures faded into each other.

    Scratchpad

    Draw a digit here

    Draw a digit to see where it lands.

    What the encoder sees 28 × 28 pixels, centered like the training data
    Drawn back from two numbers All the decoder gets to work from

    Two numbers per digit.

    An autoencoder learns to squeeze its input into a few numbers and to rebuild the input from them. With only two numbers, every digit gets a place on a map.

    Squeezing a digit into two numbers

    The encoder reads all 784 pixels and boils them down to two numbers: a place on the map. Two numbers can’t hold every detail, so it keeps what tells digits apart most, mainly which digit it is and roughly how it’s written. Digits that look alike end up close together.

    Drawing a digit from two numbers

    The decoder does the reverse. From any two numbers it draws a 28 × 28 image, giving every pixel a chance of ink. It learned by redrawing 60,000 training digits from their two numbers and being scored on how far each pixel was off.

    Why the map is smooth

    This is the variational part. In training, the encoder gives a small cloud instead of an exact point, and the decoder has to redraw the digit from a random spot in that cloud, so nearby points must decode to similar digits. A second term, the KL divergence, pulls every cloud toward the middle, so the map has no empty gaps: wherever you put the point, there’s a digit.

    Model and credits

    The network is a variational autoencoder with 469,268 parameters, trained for this site on the 60,000 training digits of the MNIST database by Yann LeCun, Corinna Cortes and Christopher J. C. Burges (CC BY-SA 3.0). The dots are 5,000 digits from the MNIST test set, which it never trained on; for most of them, most of their five nearest neighbors on the map are the same digit. The examples come from the test set too, and the “looks like” reading comes from the network on the Digits page. Everything runs in your browser; nothing you draw leaves your device.