Convolutional Neural Networks
A Convolutional Neural Network (CNN) is a specialized type of neural network designed to process grid-like data, most commonly images. Instead of treating every pixel as an independent input like a standard MLP, CNNs preserve and exploit the spatial structure of the data.
The Convolution Operation
A CNN slides a small matrix called a filter (or kernel) across the input image, computing a dot product at each position. This produces a feature map that highlights where a particular pattern - like an edge, curve or texture - appears in the image.
output_pixel = sum(filter * image_patch)
Why Not Just Use an MLP?
A standard MLP would need a separate weight for every single pixel connection, making it computationally massive and prone to overfitting for images. CNNs solve this through parameter sharing (the same filter is reused across the entire image) and local connectivity (each neuron only looks at a small region at a time).
Typical CNN Architecture
Input Image -> Convolution + Activation -> Pooling -> Convolution + Activation -> Pooling -> Fully Connected -> Output
Implementing in Python
from tensorflow.keras import layers, models
model = models.Sequential([
layers.Conv2D(32, (3,3), activation="relu", input_shape=(64,64,3)),
layers.MaxPooling2D((2,2)),
layers.Flatten(),
layers.Dense(10, activation="softmax")
])
Coming Up Next
Now that you understand how CNNs work, let's look at where they're actually used across real-world industries.