CNNs Explained: How Convolutional Neural Networks Revolutionized Computer Vision


CNN: the architecture that taught machines to see

Convolution, padding, stride, pooling, architectures, and transfer learning

How neural networks learn visual patterns and why they revolutionized computer vision.

So far we’ve lived in the universe of language: recurrent networks, memory gates, attention, Transformers, embeddings, and LLMs.

But modern artificial intelligence doesn’t just read and write: it also has eyes.

Long before Vision Transformers burst onto the scene, computer vision was built on a family of architectures that changed the rules of the game: Convolutional Neural Networks (CNNs).

CNNs were to the visual world what Transformers were to text: the definitive leap that let machines go from analyzing disconnected numbers to recognizing faces, reading X-rays, guiding self-driving cars, and understanding reality through images.

Let’s see, step by step, how they pulled off such a feat.

Diagram showing convolution, pooling, and CNN architecture flow in computer vision.


1. What is a CNN, and why did traditional networks fail?

To understand their genius, you first have to understand the disaster that came from using classic dense (feed-forward) networks on images.

Picture a modest color photo: 1000 × 1000 pixels with 3 channels (Red, Green, and Blue). That’s 3 million input values. If you connect it to a classic hidden layer of just 1000 neurons, you need 3 billion parameters in the first step alone. The network would collapse from lack of memory and fall into wild overfitting.

And there’s an even worse problem: a dense network treats each pixel as an independent variable. If you move a cat two centimeters to the right in the photo, to the network it’s a completely new enigma it has never seen before.

CNNs said enough and leaned on a fundamental visual principle:

Visual patterns don’t live in isolated pixels; they live in local regions.

A CNN doesn’t try to swallow the photo whole. It works just like the biological visual cortex: it builds its understanding of the world from the bottom up, in a natural hierarchy.


2. Convolution: the flashlight that scans the image

Convolution is the heart of the system. Instead of connecting every neuron to every pixel, the network uses a small numeric matrix called a filter or kernel (usually a compact size, 3×3 or 5×5).

The flashlight analogy. Imagine you’re in the dark in front of a large mural, holding a small flashlight. You can’t see the whole mural at once: you slide the beam of light left to right and top to bottom. Each time the flashlight focuses on a 3×3 pixel tile, the filter multiplies its numbers by the image’s numbers, adds them up, and produces a single result.

The result of that sweep is a feature map: a new version of the image that highlights only what the filter was looking for (for example, where there are vertical lines, curves, or light reflections).

And here’s the key: a convolutional layer doesn’t have a single filter, but dozens or hundreds in parallel, each specialized in «hunting» a different visual feature.


3. Padding: the lifesaver for edges

When you slide a 3×3 window over a grid, two physical problems appear right away:

  1. The center of the filter can’t rest on the extreme corners, so the output matrix ends up smaller than the original.
  2. The central pixels get scanned many times, but the edge pixels are barely touched once.

To fix this we add padding: an artificial frame (usually of zeros) around the image, like putting a mat around a painting.

Padding type What it consists of Effect on the image
Valid No padding; computed only where the filter fits fully The output shrinks at each layer
Same Rows and columns of zeros added at the margins The output keeps exactly the same size

Thanks to padding, a very deep network can stack dozens of consecutive layers without shrinking the image until it vanishes in the first steps.


4. Stride: the filter’s step

The stride determines how many pixels the filter jumps with each move:

  • Stride = 1: advances pixel by pixel. Exhaustive, slow, and detailed analysis.
  • Stride = 2: advances two cells at a time, reducing the image by half.
  • Stride > 2: wide jumps and drastic resolution reduction.

 

Increasing the stride is one of the most efficient forms of downsampling (reducing spatial dimensionality) while saving computation.


5. Pooling: synthesizing without losing what matters

If a layer detects that there’s a cat’s ear in one corner, the following layers don’t care about the exact millimeter coordinate of each pixel; it’s enough for them to know: «there’s an ear in this general area.»

That’s what pooling is for: it condenses contiguous regions, reduces the spatial size, and provides invariance to small translations (if the cat moves two pixels, the network still detects it).

There are two main flavors:

  • Max pooling (the undisputed king): divides the map into grids (typically 2×2) and keeps only the highest number. It preserves the most intense activation and discards the rest.
  • Average pooling: extracts the mean of each grid, smoothing out the activations.

Together, pooling provides three benefits: tolerance to small movements, fewer parameters, and more stable learning.


6. 1×1 convolutions: smart compression

At first glance, a 1×1 filter seems absurd: what geometric shape are you going to detect by looking at a single pixel?

The magic isn’t in the spatial plane, but in the depth, that is, in the channels. If you have a map with 256 channels (accumulated filters), a 1×1 filter acts along that entire vertical beam.

The paint mixer analogy. Imagine that at each point of the image you have 256 tubes of different colors. The 1×1 convolution mixes those 256 shades in learned proportions and condenses them, for example, into just 64 channels, without touching the width or height of the image.

It was the secret weapon of legendary architectures like Inception, ResNet, and MobileNet for:

  • reducing dimensionality before heavy operations,
  • fusing information scattered across channels,
  • and adding non-linearities (ReLU) at minimal computational cost.

7. The family tree: evolution of the great architectures

Modern computer vision can be told through the milestones that marked each competitive leap.

Architecture Year Big innovation Why it made history
LeNet-5 1998 Convolution + pooling to recognize digits (Yann LeCun) Proved convolutional theory worked in the real world.
AlexNet 2012 GPU training, ReLU, and Dropout Crushed the competition in ImageNet and ignited the Deep Learning era.
VGG 2014 Tiny stacked 3×3 filters Showed that stacking small filters and going deeper beats using large filters.
Inception 2014 Parallel multiscale modules + 1×1 filters Processed several scales at once without blowing up parameters.
ResNet 2015 Residual connections (skip connections) Solved gradient degradation and enabled training networks of over 150 layers.
EfficientNet 2019 Compound scaling (resolution + depth + width) Maximum accuracy by balancing performance and computation scientifically.

8. Transfer learning: the democratization of vision

Training a network like ResNet from scratch requires weeks of computation and millions of labeled photos (like the ImageNet dataset). If you’re a startup or an independent researcher, are you out of the game?

Not at all, thanks to transfer learning.

A CNN learns hierarchically:

  1. Its early layers detect universal lines, edges, shadows, and textures, equally useful for distinguishing a tumor, a car, or a muffin.
  2. Only the last layers specialize in the concrete task (for example, telling dog breeds apart).

You just freeze the trunk of the pretrained network, replace the last layer with one suited to your goal, and train only that final part with a few hundred photos. This technique is the real reason computer vision jumped so quickly from labs to everyday applications, within reach of startups, researchers, companies, and individual developers.


9. The three pillars of CNNs’ success

For a full decade, no other technique could overshadow them. The secret of their dominance comes down to three principles:

  1. Spatial locality: they assume that nearby pixels hold a much stronger relationship than distant ones.
  2. Weight sharing: the same edge-detecting filter is reused across the whole image. If the model learns to detect an eye in the top left, that same filter works if the eye appears in the bottom right. This reduces parameters by orders of magnitude and improves generalization.
  3. Compositional hierarchy: they assemble simple geometric primitives and turn them, automatically, into abstract high-level semantic concepts.

10. The generational handover: Vision Transformers (ViT)

Today the throne of vision is no longer the exclusive territory of CNNs. Vision Transformers (ViT) have shown that, with enough data and computation, the pure attention mechanism can fragment an image into small patches (as if they were words in a text) and find direct global relationships, without depending on the local window of convolution.

Even so, the legacy is very much alive:

  • Many modern production models are hybrids: they use convolutional blocks at the start to extract fast textures, and attention afterward to contextualize.
  • On mobile devices and resource-constrained environments, CNNs remain the queens for speed and lightness.
  • And to understand ViTs, you must first master the geometric intuition that CNNs taught us.

In summary

  • CNNs broke the visual dimensionality problem by processing images by regions instead of pixel by pixel.
  • Convolution acts as a scanner for characteristic patterns.
  • Padding and stride control the size and the pace at which the image is examined.
  • Pooling condenses relevant information and provides tolerance to small movements.
  • 1×1 convolutions mix and compress channels without distorting spatial resolution.
  • Transfer learning turned computer vision into an accessible tool for any programmer.

CNNs marked the exact moment when machines stopped storing blind maps of colors… and began interpreting the world with their own eyes.