model-insights · VGG16 · ImageNet

Inside VGG16

In 2014, VGG16 learned to sort 1.2 million photographs into 1,000 categories. It never saw a rule, only photos and labels. Everything it knows is stored in 138 million numbers, and those numbers still carry traces of the photos it learned from. This page runs the real network in your browser, takes it apart layer by layer, and shows you those traces.

Loading model weights…

1 A stack of tiny filters

VGG16 only does three things. A 3×3 convolution slides a small learned stencil over the image. A ReLU throws away negative responses. A 2×2 max-pool halves the resolution. Thirteen convolutions in five blocks turn a 224×224 photo into 512 maps of 14×14. Three fully connected layers then turn those maps into 1,000 class scores.

Each layer sees a slightly larger patch of the input than the one before. That patch is its receptive field. It grows from 3 pixels at conv1_1 to 196 pixels at conv5_3, so deeper units can respond to larger, more composite things. Click a layer to inspect it.

Layer by layer

2 The only weights you can read directly

The first layer is the only one whose weights live in pixel space, so it is the only one you can simply draw. Below are all 64 filters of conv1_1, each 3×3 pixels × RGB, enlarged. Even at this tiny size you can see the two families that show up in almost every vision network, and that loosely resemble cells in the visual cortex: color-opponent patterns (green vs. magenta, blue vs. orange) and light/dark gradients. Nothing told the network to learn these. They are simply a useful first step in describing ImageNet photos.

Each filter is normalised to its own range; mid-grey is zero. Past this layer the weights mix the 64+ channels below them, so drawing them tells you nothing. From here on we look at what the units do, not what they are.

3 Dissect an image

Pick an image, or drop, paste, or upload your own. The network runs once and keeps every intermediate activation. Each small map below is one channel: how strongly that learned detector fired at each location. Channels are sorted by how active they are on this image. Click one to look closer.

drop / paste an image

What VGG16 sees

    Where it looks (Grad-CAM for the selected class)

    Grad-CAM weights each conv5_3 channel by how much the class score would rise if that channel fired more, then sums the maps. Click a prediction to switch classes. Hot regions that sit outside the object show the model using context it picked up from its training photos. Try the astronaut: ImageNet has no "person" class, so the network reaches for the closest thing it was taught. Its top guess is "bobsled", and Grad-CAM shows that guess resting on the helmet.

    4 Ask a neuron what it wants

    Activation maps show where a channel fires, not what it is looking for. To find out, turn the question around. Start from grey noise and repeatedly nudge the pixels in whatever direction raises the unit's activation: gradient ascent on the image, with the weights frozen. ONNX can't do backpropagation, so this project exports VGG16's backward pass as an ordinary graph: transposed convolutions, ReLU masks and max-pool routing. The gradient is computed right here, by onnxruntime-web.

    Left alone, gradient ascent finds high-frequency noise that excites the unit but looks like nothing. The regularisers below fix that: random jitter, frequency-balanced gradients and gentle blurring keep only patterns that survive being shifted and smoothed. Those patterns are the ones that are actually common in natural photos.

    Offline render

    When the gallery has a high-quality render of this objective (same idea, but a Fourier-space parametrisation and 384+ steps in PyTorch), it appears here for comparison.

    5 Residues of ImageNet

    Here is where the training data shows through. Ask the network to draw "its idea" of a class by maximising that class's logit. You don't get a clean object. You get what was statistically present in the photos with that label. A neck brace turns into faces. Dumbbells come with the hands that grip them. Sunglasses come with the face behind them and a beach in the lenses. The network was only ever told "this photo is a neck brace". It had no way to know which part of the photo the label referred to, so label and context became one pattern.

    Look closely and you'll find a second residue that has nothing to do with any class. Many renders carry a faint grid of glyph-like marks, like lettering. A plausible source is the text, captions and watermarks that are common in photos scraped from the web. They're frequent enough in the training data that features for them are mixed into almost everything.

    Click any image to feed it back into the network (§3). Every one of these renders is classified as its class with roughly 100% confidence, more certain than the network is about most real photos, even when it barely resembles the object to us.

    What individual channels detect, block by block

    The same technique applied to single channels shows how the features compose. Early blocks learn colours, edges and simple gratings. conv3_3 is all textures: scales, weaves, stripes. conv5_3 learns object parts, and among them animal faces and eyes keep coming back. That fits a dataset where 120 of the 1,000 classes are dog breeds and hundreds more are other animals. The earlier blocks show an evenly spaced sample of 24 channels; conv5_3 shows all 512, so you can scroll through everything the last convolutional layer learned to look for.