0% found this document useful (0 votes)
12 views45 pages

Understanding Convolutional Neural Networks

The document provides an overview of Convolutional Neural Networks (CNNs), explaining how computers read images, the limitations of fully connected networks, and the architecture of CNNs. It discusses the working of CNNs, including convolutional, ReLU, pooling, and fully connected layers, as well as real-world applications and challenges. The document concludes with a focus on the future trends and ongoing research in CNN efficiency and interpretability.

Uploaded by

ranasezal108
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views45 pages

Understanding Convolutional Neural Networks

The document provides an overview of Convolutional Neural Networks (CNNs), explaining how computers read images, the limitations of fully connected networks, and the architecture of CNNs. It discusses the working of CNNs, including convolutional, ReLU, pooling, and fully connected layers, as well as real-world applications and challenges. The document concludes with a focus on the future trends and ongoing research in CNN efficiency and interpretability.

Uploaded by

ranasezal108
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Agenda

• How Computer Reads Images?


• Why Not Fully Connected Networks for Image
Recognition?
• What is Convolutional Neural Network?
• How Convolutional Neural Network Works?
• Real World Applications
How Computer Reads an Image?

1. Images as Grids of Pixels:


• Example: Grayscale (2D matrix) and RGB (3D matrix).
2. Numerical Representation:
• Example: A 3x3 image with RGB values.
• R = [[255, 128, 64], [255, 255, 0], [128, 0, 255]]
• G = [[64, 128, 255], [0, 255, 255], [255, 0, 64]]
• B = [[0, 0, 255], [255, 128, 128], [64, 255, 0]]

3. Importance of Resolution:
• Higher resolution = more pixels, better quality.
How Computer Reads an Image?

N : pixels across the height


M: pixels across the width
3 : number of channels
M
3
R
N
G

B
How Computer Reads an Image?

How we See? What Computer See?


Why Not Fully Connected
Networks for Image Recognition?
1. Challenges with Fully Connected Networks:
• Large number of parameters due to pixel-by-pixel connections.
• Example: For a 28x28x3 image (2352 pixels), a single-layer fully
connected network with 128 neurons has 2352×128=301,056
weights.
2. Loss of Spatial Hierarchies:
• Does not preserve spatial patterns.
3. Overfitting and Computational Inefficiency:
• Example: For a 1000x1000 image, the count becomes
unmanageable.
History of Convolutional Neural
Network (CNN)
• CNNs were first introduced by Yann LeCun with
LeNet for digit recognition tasks in the late 1980s.
The breakthrough came in 2012 when AlexNet won
the ImageNet competition, revolutionizing computer
vision.
What is a Convolutional Neural
Network?
• CNN is a type of feed-forward artificial network where the
connectivity pattern between its neurons is inspired by the
organization of the animal visual cortex.
• They automatically and adaptively learn spatial hierarchies of
features from input images. CNNs excel in image recognition
and classification tasks.
What is a Convolutional Neural
Network?
• CNN/ConvNet is a class of deep neural networks, most commonly applied to
analyze visual imagery.
• The role of the ConvNet is to reduce the images into a form that is easier to
process, without losing features.

Architecture
of CNN
Working of CNN

Convolutional Neural Networks have the following layers:


• Input Layer
• Convolutional
• ReLU Layer
• Pooling
• Fully Connected Layer
• Output Layer
Continued…

• Convolution Layer: Of the many layers of CNN, the first layer


(after the input layer) is the convolutional layer that extracts the
features from the data.
• Pooling Layer: Typically, a pooling layer follows a convolution
layer to reduce the dimensions of the input data.
• Fully Connected Layer: In a fully connected layer, nodes from
one layer connect to every other node in the next layer.
Continued…
• Flattening the input image into a single-column vector allows
the utilization of a conventional, fully connected, dense, neural
network for classification.
• Output Layer: An output layer typically utilizes a logistic
function like sigmoid or softmax to perform classification on
the output of the final fully connected layer.
• Dropout Layers: One issue with the fully connected layer is its
dense architecture can easily cause the model to overfit the
training dataset. A dropout layer randomly drops a few neurons
from the network to address this issue.
Case Study
• There are certain trickier cases where X can represent in these
four forms, so these are nothing but the effects of the
deformed images. Because X and O's are always not the same
images. Here, there are multiple presentations of X and O's.
How CNN Works?

• Computer understands an
image using numbers at
each pixel.
• In our example, we have
considered that
a blue pixel will have
value 1, and a white pixel
will have -1 value.
How CNN Works?

Using normal techniques, the computer unable to recognize these images.

Correct X Deformed X Computer unable to


recognize if it is X or not
How CNN Works?
• Using CNN, we extract small image patches, called filters, to identify rough
feature matches at the same position in two images. CNN improves similarity
detection by comparing small sections of an image, rather than matching entire
images. These filters capture specific features, even in deformed or altered
versions of the image.
How CNN Works?
• We have three
features or filters, as
shown below.
• These are small
pieces of bigger
images. We choose a
feature and put it on
the input image, if it
matches then the
image is classified
correctly.
How CNN Works?
(Example 2)
• An RGB image is nothing but a matrix of pixel values having three
planes whereas a grayscale image is the same but it has a single plane.
• For simplicity, let’s stick with grayscale images as we try to understand
how CNNs work.
How CNN Works?

Take a filter/kernel(3×3
matrix) and apply it to
the input image to get the
convolved feature. This
convolved feature is
passed on to the next
layer.
How CNN Works?

• In the case of RGB color channel, take a look at this animation to


understand its working.
Convolutional Layer

Weight/parameters

Result Matrix
• Filter pixels value
are multiplied with Filter/neuron
the corresponding / kernel
input image pixel
value and are saved
in another result
matrix.
Receptive Filed
Convolutional Layer

• Adding and
Dividing by total
number of pixels. Result of the
above Filter: 1
Convolutional Layer

• Creating a Map to put the value of the filter at the place


• We will transfer the features to every other position of the
image and will see how the features match that area.

9 x 9 Matrices Activation/Feature Map : 7 x 7 Matrices


Convolutional Layer Output

• Similarly, we perform the same convolution with every other


filter and we will get the all the filter/feature maps.
ReLU Layer
Rectified Linear unit (ReLU) transform
functions only activates a node if the input
is above a certain quantity. While the data
is below zero, the output is zero, but when
the information rises above a threshold. It
has a linear relationship with the
dependent variable.
• In this layer, we remove every negative
value from the filtered images and
replaces them with zeros.
• It is happening to avoid the values from
adding up to zero.
ReLU function applied on one
feature
• For transformed the negative values to 0, we have to
performed ReLU function for all features.
Pooling Layers

• Pooling layer will perform a down sampling


operation along the spatial dimensions (width,
height), resulting a lower volume
Symbol
• Four steps involved in pooling operation:
1. Pick a window size (usually 2-3)
2. Pick a stride (usually 2)
3. Walk your window across filtered images.
4. From each window, take the maximum
value.
Pooling Layers
To shrink the image stack into smaller size

To decrease the computational power,


required to process the data by
reducing the dimensions. Two types of
pooling: average pooling and max
pooling.
Pooling Layer

• Choose the highest value in the window and move the window
two strides.
Pooling Layer

• Moving the window across entire image

7 x 7matrix 4 x 4 matrix
Output after passing through
pooling layer
• The basic role of pooling
layer is to shrink the size
of our image matrix.
• Here we have converted a
7 x 7 matrix to a 4 x 4
matrix.
• Since we took 3 features
in the begging, we have 3
output after pooling layer.
• Now next we have to
stack up all the layers.
Stacking up the layers

4 x 4 Matrices
Input Image
Stacking up the layers

• Here we have applied one more layer of each convolution, ReLU and
pooling, in order to downsize 4 x 4 matrix to 2 x 2 matrices.
Fully Connected Layer
Actual classification take place in fully connected layer

• This is the final layer


where the actual
classification
happens.
• Here we take the
shrunk image and
put into the single list
or a vector.
• When we feed in, 'X'
and '0'. Then there
will be some element
in the vector that will
be high.
Output
• Now If we have input image
with 1𝑠𝑡 , 4𝑡ℎ , 5𝑡ℎ , 10𝑡ℎ , and
the 11𝑡ℎ value high we can
say that image is X.
• Similarly if our input image
has a list which has the
2𝑛𝑑 3𝑟𝑑 9𝑡ℎ and
𝑡ℎ
12 element vector values
are high, we can say that it is
O.
• This completes the training of
our model. Now let’s see
results on some unseen
images.
Comparing the Input Vector with
X
Comparing the Input Vector with
O
Result

The new input image is classified as ‘X’.


Use case
Similarly, If we
train our model
with dataset of
Dogs and cats.
Once training is
done, our model
will be able to
predict a new
unlabeled input
correctly.
CNN Structure

Model Summary
Real-World Applications of
CNNs
• Image Classification
• Object Detection
• Image Segmentation
• Medical Diagnostics
• Natural Language Processing
Feature Hierarchies in CNNs

• Low-Level Features: Simple patterns like edges.


• Mid-Level Features: Shapes and contours.
• High-Level Features: Complex patterns such as full objects.
Key CNN Architectures

• LeNet-5
• AlexNet
• VGGNet
• ResNet
Challenges of CNNs

• Data Hungry
• Computationally Intensive
• Interpretability
Conclusion and Future Trends

• CNNs revolutionized computer vision. Ongoing research


focuses on efficiency, interpretability, and expanding
applications beyond image data.
References

• [Link]
nvolutional-neural-networks-cnn/
• [Link]
convolutional-neural-network-tensorflow
• [Link]
neural-network/

You might also like