Deep learning visualizer

CNN Feature Map Explorer

Explore how convolutional layers transform an image into learned visual features.

ModelSimple CNNLayerConv2Channels16Map14 x 14

Input image

Digit 7
Input
28 x 28

Feature Maps: Conv2

Channel 6 / 16
HighLow

Input

28 x 28

Selected Filter (Conv2, Ch 6)

-0.7-0.1-0.64-0.020.590.04-0.150.45-0.09
3 x 3

Channel 6 Activation (14 x 14)

Position [9, 8]Activation 2.04Receptive field 5 x 5

Features become more abstract with depth

Input
Pixels
Early layer
Edges
Middle layer
Patterns
Deeper layer
Shapes

How feature maps work

  1. Convolutional filters slide across the input and compute dot products.
  2. Each filter responds strongly to specific patterns at different locations.
  3. The response values form a feature map highlighting where patterns occur.
  4. Deeper layers combine simpler patterns into more complex representations.

Implementation

  1. import torch.nn as nn
  2. model = SimpleCNN()
  3. activations = {}
  4. def get_activation(name):
  5. def hook(model, input, output):
  6. activations[name] = output.detach().cpu()
  7. return hook
  8. model.conv2.register_forward_hook(get_activation('conv2'))