๐Ÿ”ฅLimited Offer: Get 50% OFFon AI & Full Stack Courses๐Ÿ”ฅ
Back to Deep Learning Notes
Topic #160

What Is CNN?

A Convolutional Neural Network (CNN) is a neural network architecture specialized for grid-structured data โ€” most commonly images โ€” built around a single core operation, convolution, that fundamentally changes how a network connects to its input compared to the fully-connected MLPs covered earlier in this hub.

The High-Level Idea

Instead of connecting every input pixel to every neuron (as an MLP would), a CNN slides small, learnable filters across the image, each one detecting a specific local pattern โ€” an edge, a texture, a color transition โ€” at every position. Stacking several such layers builds up a hierarchy: early layers detect simple patterns (edges, corners), middle layers combine these into more complex shapes (textures, object parts), and later layers assemble those into recognizable whole objects.

A Typical CNN Pipeline

Input Image Conv + ReLU Pooling (repeated) Conv + Pool Flatten Fully Connected Layer(s) → Output (class probabilities)

Convolution and pooling layers extract increasingly abstract spatial features; flattening and fully connected layers turn those features into a final prediction.

Code โ€” A Minimal CNN

import torch.nn as nn

model = nn.Sequential(
    nn.Conv2d(in_channels=3, out_channels=16, kernel_size=3, padding=1),   # convolution
    nn.ReLU(),
    nn.MaxPool2d(kernel_size=2),                                            # pooling

    nn.Conv2d(16, 32, kernel_size=3, padding=1),
    nn.ReLU(),
    nn.MaxPool2d(kernel_size=2),

    nn.Flatten(),
    nn.Linear(32 * 8 * 8, 10)   # fully connected output layer (assuming input was 32x32)
)

Every Term in the Rest of This Category, Previewed

TermRole
ConvolutionThe sliding, weight-sharing pattern-detection operation itself
Kernel / FilterThe small learnable weight matrix that gets slid across the input
Feature mapThe output produced by applying one filter across the whole input
Stride, paddingControls over how the kernel moves and how edges are handled
PoolingDownsampling feature maps to reduce size and add robustness

Common Mistakes

  • Assuming a CNN is just "an MLP for images" with no structural difference โ€” the entire point of convolution (covered starting next note) is a fundamentally different, far more parameter-efficient way of connecting to spatial input, not simply a renamed MLP.
  • Thinking CNNs are exclusively for images โ€” the same convolution operation applies to any grid-like, spatially-structured data (1-D convolutions for audio/time-series, 3-D convolutions for video or volumetric medical scans).

Interview Relevance

Q: "At a high level, what makes a CNN different from a standard fully-connected network?" A CNN uses convolution โ€” sliding small, learnable filters across the input, sharing the same weights at every spatial position โ€” instead of connecting every input value to every neuron. This gives CNNs far fewer parameters for image-sized inputs, an inductive bias toward detecting local patterns, and a degree of translation invariance that plain MLPs lack entirely.

Practice Question

In your own words, why might a network built from convolution operations naturally suit image data better than one built purely from fully-connected layers?

Want to go beyond the notes?

Join CodingNow 2.0's Deep Learning course โ€” live mentorship, real projects, and 100% placement support.

Enroll Now โ€” Free Demo Available

What Is CNN? โ€“ FAQs

Quick answers about learning What Is CNN? in Deep Learning.

This free note from CodingNow 2.0 explains What Is CNN? in Deep Learning โ€” concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every Deep Learning topic on CodingNow 2.0, including What Is CNN?, is 100% free with no signup required.
With focused practice, most students grasp What Is CNN? in 1โ€“3 days from these notes; pairing it with CodingNow 2.0's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the CodingNow 2.0 Community (/community) โ€” expert instructors answer within 24 hours.
WhatsApp
Call NowEnroll Now