Skip to main content
Interactive Computer Vision Engine

CNN Operations Visualizer

Master the fundamental computational building blocks of Convolutional Neural Networks. Toggle between Convolution Operation (sliding filter kernels & Frobenius inner products) and Max Pooling (spatial dimensionality downsampling & peak activation routing) in real time.

Technical Overview: 2D Convolution and Max Pooling Operations in Convolutional Neural Networks (CNNs)

1. What is a 2D Discrete Convolution Operation?

A convolution operation in deep learning is a spatial mathematical transformation where a learnable matrix of weights called a filter kernel (such as 3×3 or 5×5) slides across an input image. At each step, it computes the Frobenius inner product (sum of element-wise products) between the kernel and the local input receptive field window:

S(i, j) = (I * K)(i, j) + b = ∑m=0Kh-1 ∑n=0Kw-1 I(i·sv + m, j·sh + n) K(m, n) + b

This generates an output feature map highlighting visual primitives including vertical edges, horizontal boundaries, ridges, and textures.

2. What is a Max Pooling Operation?

A max pooling operation is a non-linear spatial downsampling technique placed after convolutional layers. It slides a rectangular window (typically 2×2 with stride 2) across the feature map and selects the maximum scalar activation:

y(i, j) = max(m,n)∈W x(i·sv + m, j·sh + n)

Max pooling achieves 75% spatial dimensionality reduction, cuts FLOP computation, establishes local translation invariance, and widens the receptive field of subsequent layers.

3. Spatial Dimension Calculation Formulas

Given input spatial dimension W, filter size K, zero-padding P, and stride S:

  • Convolution Output Dimension: O = ⌊(W - K + 2P) / S⌋ + 1
  • Max Pooling Output Dimension: Oh = ⌊(H - Fh) / Sv⌋ + 1 and Ow = ⌊(W - Fw) / Sh⌋ + 1

4. Comparison: Convolution vs. Max Pooling

Property 2D Convolution Operation Max Pooling Operation
Primary Goal Feature extraction (edges, motifs, textures) Spatial dimensionality reduction & translation invariance
Parameters Learnable weights (e.g. 9 weights per 3×3 filter) + bias 0 learnable parameters (deterministic max operator)
Mathematical Function Frobenius inner product (sum of products + bias) Max element selection (max(v1, v2, ...))
Gradient Flow Gradients disperse across all 9 kernel weights 100% gradient routes to single winning max neuron