Introduction to Deep Learning CNN
Introduction to Deep Learning CNN
❑ Deep learning is a subfield of machine learning that uses artificial neural networks with
multiple layers (hence "deep") to analyze and learn from data.
❑ Deep Learning is transforming the way machines understand, learn, and interact with
complex data.
❑ Deep Learning leverages artificial neural networks (ANNs) to process and learn from
complex data.
1. What is deep learning?
❑ Machine learning and Deep Learning both are subsets of artificial intelligence but there are many
similarities and differences between them.
Ch-5 Introduction to Deep Learning & CNN
❑ Deep learning should be considered when you have large amounts of data, especially
unstructured or unlabeled data, and when complex, non-linear patterns need to be identified.
❑ It's particularly useful for tasks where feature engineering is difficult or time-consuming, and
where the goal is to achieve high accuracy and automation.
1. When Data is Abundant: Deep learning thrives on large datasets, often requiring millions of
data points to train effectively. Traditional machine learning algorithms can struggle with
such volumes, while deep learning models can learn complex patterns from vast amounts of
information.
2. When Data is Unstructured: Deep learning excels at processing raw data formats like
images, audio, and text, where features are not explicitly defined. Algorithms like
convolutional neural networks (CNNs) and recurrent neural networks (RNNs) are
specifically designed to extract features from these types of data.
3. When to use Deep Learning?
❑ ...
3. When Feature Engineering is Challenging: Deep learning can automate feature extraction,
reducing the need for manual engineering of features. This is particularly beneficial in
domains like computer vision and natural language processing, where identifying relevant
features can be complex.
4. When High Accuracy is Critical: Deep learning models can achieve high levels of accuracy
in various tasks, often surpassing traditional machine learning algorithms, especially when
dealing with complex problems. This is due to their ability to learn intricate non-linear
relationships in the data.
5. When Automation is Desired: Deep learning models can be trained to perform tasks with
minimal human intervention, making them ideal for applications like self-driving cars, object
detection, and image recognition.
3. When to use Deep Learning?
❑ Feed forward neural networks are artificial neural networks in which nodes do not form loops.
❑ This type of neural network is also known as a multi-layer neural network as all information is
only passed forward.
❑ During data flow, input nodes receive data, which travel through hidden layers, and exit output
nodes.
4. Deep Feedforward Networks, Example: Learning XOR
➢ This is because the XOR function is not linearly separable, meaning a single line cannot
separate the (0,0) and (1,1) points from the (0,1) and (1,0) points.
➢ A DFN can overcome this by introducing a hidden layer that transforms the input space into a
space where the XOR function is linearly separable.
4. Deep Feedforward Networks, Example: Learning XOR
print("Predictions:")
for i in range(len(X)):
print(f"Input: {X[i]} => Predicted Output: {predictions[i]}, Actual Output: {y[i]}")
Ch-5 Introduction to Deep Learning & CNN
➢ Convolutional Neural Network, CNN or ConvNet is a type of deep learning algorithm where
a mathematical operation known as convolution is used instead of the traditional general
matrix multiplication, at least in one of the hidden layers.
o Multiplying pixel values with neuron weights and summing them is known as convolution,
and the layer is referred to as a convolution layer - It’s important to note that this
multiplication is more peculiar.
o Neurons in the CNN consider pixel patches as input, multiplying pixel color values by
assigned weights.
4. Convolution Neural Networks (CNN) – Convolutional Layer: Filters,
Stacking Multiple Feature Maps, TensorFlow Implementation, Pooling
Layer
❑ How does CNN Work ?
➢ Convolution: . . .
o The neuron sums these products and passes the result through an activation function,
capturing essential image characteristics.
o A Convolutional Neural Network can comprise multiple such convolutional layers (along
with other layers of CNN discussed in the next section), each having an activation function
to detect features.
o The activation function in the convolution layers is typically responsible for inducing non-
linearity in the network so that complex learning can occur.
4. Convolution Neural Networks (CNN) – Convolutional Layer: Filters,
Stacking Multiple Feature Maps, TensorFlow Implementation, Pooling
Layer
❑ How does CNN Work ?
➢ Convolution: . . .
4. Convolution Neural Networks (CNN) – Convolutional Layer: Filters,
Stacking Multiple Feature Maps, TensorFlow Implementation, Pooling
Layer
❑ How does CNN Work ?
➢ Convolution: . . .
4. Convolution Neural Networks (CNN) – Convolutional Layer: Filters,
Stacking Multiple Feature Maps, TensorFlow Implementation, Pooling
Layer
❑ How does CNN Work ?
➢ Convolution: . . .
o While the first hidden layer detects basic features in an image, such as the vertical,
diagonal, and horizontal edges, the next few layers extract more complicated features.
o The output of the first hidden layer gets fed to the next layer, which extracts corners, a
combination of edges, and other complicated features.
o The third layer considers the output of the second layer as its input and, in turn, extracts
even more complicated features.
o As you progress deeper into the network, increasingly complex features are extracted, and
the final layers specialize in detecting higher-level features such as faces, objects, and so
on.
4. Convolution Neural Networks (CNN) – Convolutional Layer: Filters,
Stacking Multiple Feature Maps, TensorFlow Implementation, Pooling
Layer
❑ How does CNN Work ?
➢ Convolution: . . .
o While the first hidden layer detects basic features in an image, such as the vertical,
diagonal, and horizontal edges, the next few layers extract more complicated features.
o The output of the first hidden layer gets fed to the next layer, which extracts corners, a
combination of edges, and other complicated features.
o The third layer considers the output of the second layer as its input and, in turn, extracts
even more complicated features.
o As you progress deeper into the network, increasingly complex features are extracted, and
the final layers specialize in detecting higher-level features such as faces, objects, and so
on.
4. Convolution Neural Networks (CNN) – Convolutional Layer: Filters,
Stacking Multiple Feature Maps, TensorFlow Implementation, Pooling
Layer
❑ How does CNN Work ?
➢ Output:
o The output layer’s activation function decides how the output is provided. Typically, the
activation function is set to return values between 0 and 1, indicating the network’s
confidence in associating the input image with a class.
o For example, a convolution network classifies apples, oranges, and peaches, will return
probabilities for each class for an input image.
o These probabilities will indicate how likely the input image belongs to each class. So if we
get 40% for apples, 25% for oranges, and 35% for peaches, then as per the network, the
input image is probably of an apple.
4. Convolution Neural Networks (CNN) – Convolutional Layer: Filters,
Stacking Multiple Feature Maps, TensorFlow Implementation, Pooling
Layer
❑ How does CNN Work ?
➢ Backpropagation:
o The key aspect of deep neural networks, including Convolutional Neural Networks (CNNs),
involves adjusting neuron weights to extract accurate features from images - This process,
known as training, begins with a large, well-labeled training dataset.
o The training begins by assigning random weights to each neuron - Each labeled image in
the training dataset is processed with these random values, producing a predicted label.
o The predicted label is then compared with the image’s actual label. If they don’t match,
which is likely initially, the neurons’ weights are slightly adjusted, and the network is re-
run to make a new prediction.
4. Convolution Neural Networks (CNN) – Convolutional Layer: Filters,
Stacking Multiple Feature Maps, TensorFlow Implementation, Pooling
Layer
❑ How does CNN Work ?
➢ Validation:
o After completing the training, the network is evaluated on the test dataset, an untouched
labeled dataset not used for training. The trained network makes predictions on this test
dataset. If the network performs similarly to the testing phase, the model is considered to
generalize well. If, for some reason, it performs worse, the model is considered
‘overfitted’.
o Overfitting typically happens due to a lack of variety in images in the training data,
networking going through too many epochs during the training, or other reasons arising
from incorrect values of various parameters.
o As you can see, the working of CNN is similar to other neural networks, with the
difference being how it processes the input.
4. Convolution Neural Networks (CNN) – Convolutional Layer: Filters,
Stacking Multiple Feature Maps, TensorFlow Implementation, Pooling
Layer
❑ CNN Architecture
➢ Most crucial layers of a convolutional neural network:
➢ Convolution Layer :
o Of the many layers of CNN, the
first layer (after the input layer)
is the convolutional layer that
extracts the features from the
data.
➢ 1) LeNEt
➢ VGGNet
o Visual Geometry Group – an engineering
science research group at the University
of Oxford designed and developed
VGGNet that uses small convolutional
filters of size 3×3 but has a deep
architecture with layers up to 19.
o This allows the network to learn
increasingly complex features. It uses
max pooling layers to reduce the feature
map’s spatial resolution and increase the
receptive field, making the network
recognize objects of varying orientations
and scales.
4. Convolution Neural Networks (CNN) – Convolutional Layer: Filters,
Stacking Multiple Feature Maps, TensorFlow Implementation, Pooling
Layer
❑ Types of convolutional neural networks : most common types of neural networks that are still
commonly used.
➢ AlexNet
➢ GoogLeNet
o Developed by researchers at Google,
GoogleNet won the ILSVRC. It consists of
multiple parallel convolutional layers. Each
of these parallel layers has different filter
sizes, followed by a pooling layer and the
concatenation of outputs. This parallel
architecture allows for learning features at
multiple resolutions and scales.
➢ GoogLeNet . . .
◼ https://www.geeksforgeeks.org/introduction-deep-learning/
◼ https://www.geeksforgeeks.org/how-neural-networks-solve-the-xor-problem/
◼ https://www.analytixlabs.co.in/blog/convolutional-neural-
network/#How_does_CNN_work