DL Lesson 31 – Introduction to CNNs | Dataplexa

Introduction to Convolutional Neural Networks (CNNs)

In the previous lessons, we focused on fully connected neural networks and learned how neurons process numerical data.

However, when it comes to images, videos, or spatial data, traditional neural networks struggle.

This limitation led to the development of Convolutional Neural Networks (CNNs).


Why Traditional Neural Networks Fail for Images

Consider a simple image of size 64 × 64 pixels.

That single image already contains 4,096 input values.

If we connect each pixel to every neuron, the model becomes:

• Extremely large • Very slow • Highly prone to overfitting

More importantly, fully connected networks do not understand spatial relationships.


The Key Idea Behind CNNs

CNNs are inspired by how the human visual system works.

Instead of looking at the entire image at once, the brain focuses on small regions, detecting simple patterns first.

CNNs follow the same idea:

They learn from local patterns and gradually combine them into higher-level representations.


Local Receptive Fields

A CNN neuron does not see the whole image.

It only looks at a small window, such as a 3 × 3 or 5 × 5 region.

This small window is called a receptive field.

By sliding this window across the image, the network learns spatial features efficiently.


Parameter Sharing

Another major advantage of CNNs is parameter sharing.

The same set of weights is applied across different image regions.

This drastically reduces:

• Number of parameters • Memory usage • Training time

At the same time, it allows the model to detect patterns anywhere in the image.


From Edges to Objects

CNNs learn features hierarchically.

Early layers detect:

• Edges • Corners • Simple textures

Middle layers detect:

• Shapes • Parts of objects

Deeper layers detect:

• Faces • Cars • Animals • Complex objects


A Very Simple CNN Example

Let us look at a minimal CNN structure using a deep learning framework.

from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Conv2D, Flatten, Dense

model = Sequential([
    Conv2D(32, (3,3), activation='relu', input_shape=(64,64,3)),
    Flatten(),
    Dense(10, activation='softmax')
])

model.summary()

Do not worry if this looks complex.

Each component will be explained step by step in upcoming lessons.


Why CNNs Are So Powerful

CNNs work well because they:

• Preserve spatial structure • Reduce parameters • Learn meaningful visual patterns • Scale well to large images

This is why CNNs dominate computer vision tasks today.


Real-World Applications

CNNs are used in:

• Face recognition • Medical image diagnosis • Self-driving cars • Object detection • Handwritten digit recognition

Almost every image-based AI system relies on CNNs.


Mini Practice

Think about this:

Why is detecting edges more useful than memorizing pixels?


Exercises

Exercise 1:
Why are CNNs better than fully connected networks for images?

Because CNNs preserve spatial structure and use far fewer parameters.

Exercise 2:
What is the role of local receptive fields?

They allow neurons to focus on small image regions and learn local patterns.

Quick Quiz

Q1. What problem do CNNs primarily solve?

Learning spatial patterns efficiently from images.

Q2. Do CNNs use the same weights across an image?

Yes, this is called parameter sharing.

In the next lesson, we will go deeper into the core operation of CNNs — the convolution operation and understand exactly how filters extract features from images.