Updated Module 3
Updated Module 3
designed to automatically learn hierarchical representations and patterns from vast amounts
of data. They are structured to process complex, unstructured data like images, audio, and
text, mimicking the way human brains analyse information.
Convolutional Neural Networks (CNNs), also known as ConvNets, are neural network
architectures inspired by the human visual system and are widely used in computer vision
tasks. They are designed to process structured grid-like data, especially images by capturing
spatial relationships between pixels.
Automatically learn hierarchical features through convolution operations, from
simple edges and textures to complex shapes and objects.
Detect objects at different positions within an image, ensuring robustness to
spatial variations.
Reduce computational complexity by processing local regions instead of the
entire image at once
Key Components
Working of CNN
1. Input Image: CNN receives an input image which is pre-
processed to ensure uniformity in size and format.
2. Convolutional Layers: Filters are applied to the input
image to extract features like edges, textures and
shapes.
3. Pooling Layers: The feature maps generated by the
convolutional layers are downsampled to reduce
dimensionality.
4. Fully Connected Layers: The downsampled feature
maps are passed through fully connected layers to
produce the final output, such as a classification label.
5. Output: The CNN outputs a prediction, such as the class
of the image
Introduction to LeNet-5
LeNet-5 is a convolutional neural network (CNN) architecture that
introduced several key features and innovations that have become
standard in modern deep learning. It demonstrated the effectiveness
of CNNs for image recognition tasks and introduced key concepts
such as convolution, pooling, and hierarchical feature extraction that
underpin modern deep learning models.
Originally designed for handwritten digit recognition, the principles
behind LeNet-5 have been extended to various applications,
including:
Handwriting recognition in postal services and banking.
Object and face recognition in images and videos.
Autonomous driving systems for recognizing and interpreting
road signs.
The architecture of LeNet 5 contains 7 layers excluding the input
layer. Here is a detailed breakdown of the LeNet-5 architecture:
1. Input Layer
Details of Layers
Convolutional Layers (Cx): These layers apply convolution
operations to the input, using multiple filters to extract different
features. The filters slide over the input image, computing the dot
product between the filter weights and the input pixels. This process
captures spatial hierarchies of features, such as edges and textures.
Subsampling Layers (Sx): These layers perform pooling
operations (average pooling in the case of LeNet-5) to reduce the
spatial dimensions of the feature maps. This helps to control
overfitting, reduce the computational load, and make the
representation more compact.
Fully Connected Layers (Fx): These layers are densely
connected, meaning each neuron in these layers is connected to
every neuron in the previous layer. This allows the network to
combine features learned in previous layers to make final
predictions.
2. AlexNet (2012)
AlexNet is a deep learning model that made a big impact in
image recognition. It became famous for its ability to classify
images accurately. It won the ImageNet Large Scale Visual
Recognition Challenge (ILSVRC) 2012 with a top-5 error rate
of 15.3% (beating the runner up which had a top-5 error rate
of 26.2%).
Most important features of the AlexNet are:
Overfitting Prevention: Dropout (0.5) was applied to
the first two fully connected layers and data
augmentation dynamically expanded the dataset hence
both helping in reducing overfitting.
Faster Training: ReLU activation was used instead of
tanh or sigmoid, leading to a 6× speedup in training by
avoiding activation saturation.
AlexNet Architecture
Its architecture includes:
5 convolutional layers with Max-Pooling applied after
the 1st, 2nd and 5th layers to enhance feature
extraction.
Overlapping Max-Pooling uses a 3×3 filter with stride
2 which improved performance by reducing top-1 error
by 0.4% and top-5 error by 0.3% compared to non-
overlapping pooling.
Followed by 2 fully connected layers each using
dropout to prevent overfitting.
Ends with a softmax layer for final classification.
Advantages of AlexNet
Use of ReLU Activation: First major architecture to use
ReLU (Rectified Linear Unit) which enabled faster training
compared to traditional tanh/sigmoid functions.
Dropout for Regularization: Introduced dropout layers
to reduce overfitting by randomly disabling neurons
during training.
GPU Utilization: Split the network across two GPUs,
showing how deep learning can benefit from parallel
computing for faster training.
Overlapping Max-Pooling: Used overlapping pooling
layers to improve generalization and reduce top-1 and
top-5 classification errors.
Disadvantages of AlexNet
Large Model Size: Has around 60 million parameters
making it memory-intensive and slow for inference on
low-resource devices.
High Computational Cost: Training is computationally
expensive even though it was optimized for GPUs.
Not Optimal for Small Datasets: Tends to overfit on
smaller datasets like CIFAR-10 or MNIST without heavy
regularization.
Applications
1. Image Classification: Originally built for classifying
high-resolution images into 1000 object categories
(ImageNet dataset).
2. Feature Extraction: Intermediate layers are often used
as pretrained feature extractors for transfer learning
tasks.
3. Object Detection: Forms the backbone in early
detection systems like R-CNN when combined with region
proposal methods.
4. Medical Imaging: Applied to classify abnormalities in X-
rays, MRIs or retinal scans by fine-tuning on domain-
specific datasets.
5. Facial Recognition and Emotion Detection: Can be
adapted for face verification, expression analysis or
identity recognition tasks.
6. Autonomous Vehicles: Used in early perception
modules for identifying road signs, pedestrians or
obstacles.
VGG-19 Architecture
VGG (Visual Geometry Group) is a widely used, deep convolutional neural
network (CNN) architecture designed by Oxford University in 2014, famous for
its simplicity and uniform structure. It uses stacked convolutional layers,
allowing for increased depth (16–19 layers) which significantly improved
performance on ImageNet.
VGG-19 is a deep convolutional neural network with 19 weight
layers, comprising 16 convolutional layers and 3 fully connected
layers. The architecture follows a straightforward and repetitive
pattern, making it easier to understand and implement.
The key components of the VGG-19 architecture are:
1. Convolutional Layers: 3x3 filters with a stride of 1 and
padding
of 1 to preserve spatial resolution.
2. Activation Function: ReLU (Rectified Linear Unit)
applied after each convolutional layer to introduce non-
linearity.
3. Pooling Layers: Max pooling with a 2x2 filter and a
stride of 2 to reduce the spatial dimensions.
4. Fully Connected Layers: Three fully connected layers
at the end of the network for classification.
5. Softmax Layer: Final layer for outputting class
probabilities.
GoogLeNet Model
GoogLeNet (Inception V1) is a deep convolutional neural network
architecture designed for efficient image classification. It
introduces the Inception module, which performs multiple
convolution operations (1x1, 3x3, 5x5) in parallel, along with
max pooling and concatenates their outputs. The architecture is
deep, yet optimized for speed and performance, which makes it
suitable for large-scale visual recognition tasks. It brought
forward innovative architectural choices such as 1×1
convolutions, global average pooling and the Inception module,
all aimed at improving depth and computational efficiency.
Key Features of GoogLeNet
It uses many different kinds of methods such as:
1. 1×1 Convolutions
One of the core techniques employed in GoogLeNet is the use of
1×1 convolutions, primarily for dimensionality reduction. These
layers help decrease the number of trainable parameters while
enabling deeper and more efficient architectures.
2. Global Average Pooling
In traditional architectures like AlexNet, fully connected layers at
the end introduce a large number of parameters. GoogLeNet
replaces these with Global Average Pooling, which computes the
average of each feature map (e.g. converting 7×7 maps to 1×1),
this significantly reduces the model’s parameter count and
solves overfitting.
Benefits:
Zero additional trainable parameters
Reduces overfitting
Improves top-1 accuracy by approximately 0.6%
3. Inception Module
[Link] Classifiers
Residual Networks
To overcome the challenges of training very deep neural
networks, Residual Networks (ResNet) was introduced, which
uses skip connections that allow the model to learn residual
mappings instead of direct transformations making deep neural
networks easier to train.
It helps prevent vanishing gradient problems in very
deep models.
Skip connections let information flow directly across
layers.
ResNet enables building networks with hundreds or even
thousands of layers.
It is widely used in computer vision tasks like image
classification and object detection.
A residual block lets the network skip layers by adding the
original input to the processed output, making deep networks
easier to train.
Challenges in Deep Neural Networks
Deep Neural Networks are useful models but they also come with
several training challenges, especially as the network depth
increases.
Two major issues are
1. Vanishing/Exploding Gradient Problem: As the number of
layers in a neural network increases, the gradients of the loss
function with respect to the weights can become extremely small
or excessively large during backpropagation.
2. Degradation Problem: The degradation problem occurs
when increasing the network depth does not improve
performance and may even worsen it. This problem has two
aspects:
Performance Plateau: Training error saturates after a
certain depth meaning additional layers do not
significantly reduce the error.
Accuracy Degradation: Beyond a certain depth
validation error increases and the model performs poorly
on unseen data.
What Is Residual Learning?
Normally, a few layers in a neural network try to learn
a direct mapping:
H(x) = output we want
x = input to those layers
So, the layers learn:
H(x)
ResNet changes this idea.
Instead of learning H(x) directly, it asks the layers to
learn the difference between the input and output:
F(x) = H(x) — x
Then it adds the input back at the end:
H(x) = F(x) + x
This addition is called a skip connection or shortcut
connection because the input “skips” the layers and
gets added to the output.
ResNet
ResNet is a deep learning architecture designed to train very
deep networks efficiently using residual connections. The key
features of ResNet:
Residual Connections: Enable very deep networks by
allowing gradients to flow through identity shortcuts,
reducing the vanishing gradient problem.
Identity Mapping: Simplifies training by learning
residual functions instead of full mappings.
Depth: Supports extremely deep architectures for
improved image recognition performance.
Fewer Parameters: Achieves high accuracy with fewer
parameters hence improving computational efficiency.
Results: Delivers top performance on benchmark image
recognition tasks.
Effective Approach: Residual connections provide a
reliable way to train deeper networks effectively,
enabling networks to learn more complex features.
Here, the graph compares the training and test error of a 20-
layered and 56-layered network across iterations showing how
deeper networks struggle without proper residual connections.
ResNet-34
ResNet-34 is a deep residual network built on a 34-layer
plain network inspired by VGG-19, with shortcut
connections forming 16 residual blocks.
Here are the different stages of the ResNet-34 architecture,
showing its structured arrangement of residual blocks.
First set: 3 residual blocks each with 2 convolution
layers of 64 filters and identity skip connections.
Second set: 4 residual blocks each with 2 convolution
layers of 128 filters uses zero-padding or 1x1 projections
for dimension changes.
Third set: 6 residual blocks, each with 2 convolution
layers of 256 filters.
Fourth set: 3 residual blocks with 2 convolution layers
of 512 filters each.
Feature map: Passed through Global Average Pooling a
dense layer with 1000 neurons and softmax for
classification.
Advantages
Eases Training of Deep Networks: Skip connections
allow gradients to flow directly through the network,
reducing vanishing gradient problems.
Enables Very Deep Architectures: ResNet can train
networks with 50, 100 or even 152+ layers effectively.
Improves Accuracy: Residual learning helps the
network achieve higher performance on tasks like image
classification and object detection.
Reduces Degradation: Adding more layers does not
increase training error unlike plain deep networks.
Fewer Parameters for Better Efficiency: Deep
ResNets can have fewer parameters than traditional
deep networks but performing better.
Challenges
High Computation: Requires high computational power
due to deep architecture.
Dimension Mismatch: Dimension mismatch in skip
connections needs extra projection layers.
Overfitting Risk: Risk of overfitting on small datasets
because of large model capacity.
Training Instability: Training can become unstable
without proper batch normalization.
Redundant Updates: Residual blocks may learn only
small or redundant updates.
Deep Network Degradation: Gradient flow improves
but may still degrade in extremely deep networks.