Modules / Deep Learning / Convolutional Layer

Feature Map in CNN

Slide a kernel across an image to perform multiplications and generate a feature map.

Filter Kernel (3x3)

Understanding Convolutional Feature Maps

The core building block of how Convolutional Neural Networks (CNNs) see the world.

Quick Context

The convolution operation is the heart of Convolutional Neural Networks (CNNs), the models that power most modern computer vision. This interactive visualizes that exact process. A small matrix, called a kernel or filter, slides over an input image. At each position, it performs an element-wise multiplication and sums the results to produce a single pixel in the output, known as a feature map.

The Core Idea: Learning to See Features

Why do this? Because different kernels are designed to detect different features. One kernel might be good at finding vertical edges. Another might detect horizontal edges. A more complex one might activate when it sees a certain texture or curve. The resulting feature map is an image that shows "where" in the input the kernel found the feature it's looking for.

In a real CNN, the network learns the best kernel values during training to solve a specific task (like classifying cats vs. dogs). Here, you can manually set the kernel to build intuition for how they work.

Guided Experiments with This Interactive

  1. The "Identity" Kernel:

    Select the Identity kernel. Notice the output feature map is identical to the input image. This is because the kernel has a '1' in the center and '0's elsewhere. It's a perfect baseline—it doesn't change anything.

  2. Edge Detection Kernels:

    Draw a vertical line. Now, select the Edge Detection (Vert) kernel. The feature map will light up strongly along the line you drew. Now, select the Edge Detection (Horz) kernel. The feature map will be much darker. This demonstrates how specific kernels are tuned to find specific orientations.

  3. The "Sharpen" Kernel:

    Draw a simple shape. Apply the Sharpen kernel. The output will look like a crisper, more defined version of your drawing. This kernel emphasizes differences between a pixel and its neighbors.

  4. The Role of Bias:

    Reset to the Identity kernel. Now, set the Bias to 50. The entire feature map becomes brighter. A positive bias increases the activation of every output pixel, while a negative bias decreases it. It's a simple way to make the neuron more or less likely to fire.

  5. Applying ReLU:

    Select the Edge Detection (Vert) kernel and check the Apply ReLU box. ReLU (Rectified Linear Unit) is an activation function that clips all negative values to zero. Notice how all the red areas (negative values) in the feature map disappear, leaving only the green (positive) ones. This is a crucial step in real neural networks to introduce non-linearity.

  6. Animate the Matrix:

    Click the Animate Matrix button. This is the most important part! Watch how the 3x3 kernel slides over the input, and how the highlighted 3x3 grid of input pixels is multiplied by the kernel to produce the single highlighted pixel in the output. This is the convolution operation in action.

Common Misconceptions

  • "It's just matrix multiplication." Not quite. It's a series of smaller, element-wise multiplications and sums, not one large matrix multiplication.
  • "The output is always smaller." Not necessarily. Techniques like "padding" (adding a border of zeros to the input) can be used to keep the output the same size, as is done in this interactive.

Key Takeaways

  • A kernel is a small filter that detects a specific feature.
  • A feature map is the output of the convolution, showing where the feature was detected.
  • A single convolutional layer in a CNN has many different kernels, each producing its own feature map.
  • The combination of convolution, bias, and an activation function (like ReLU) forms the fundamental building block of a CNN layer.

By stacking layers of these feature detectors, CNNs can learn to recognize increasingly complex patterns, from simple edges to eyes, faces, and entire objects.

Cheat sheet

Convolutional Layer

The convolution operation is the heart of Convolutional Neural Networks (CNNs), the models that power most modern computer vision. This interactive visualizes that exact process. A small matrix, called a kernel or filter, slides over an input image. At each position, it performs an element-wise multiplication and sums the results to produce a single pixel in the output, known as a feature map.

COMPUTER VISION · vizlearn.in/computer_vision/feature_map_in_cnn.html