Machine Learning Unit 3
Machine Learning Unit 3
Machine Learning Unit 3
UNIT 3
CONVOLUTIONAL NEURAL NETWORK
•A Convolutional Neural Network, or CNN, is a
subset of deep learning and neural networks most
commonly used to analyze visual imagery.
•In machine learning, a convolution is the integral
measurement of how two functions overlap as they
interact.
• A ConvNet usually has 3 types of layers:
1) Convolutional Layer (CONV)
2) Pooling Layer (POOL)
3) Fully Connected Layer (FC)
• Convolution
The main building block of CNN is the convolution layer.
Convolution is a mathematical operation to merge two sets
of information.
• Pooling
After a convolution operation we usually perform pooling to
reduce the dimensionality.
• Fully Connected
After the convolution + pooling layers we add a couple of fully
connected layers to wrap up the CNN architecture.
Flattening
•Flattening is converting the data into a
1-dimensional array for inputting it to the next layer.
•We are making a classification model, which means
these processed data should be good input to the
model. It needs to be in the form of a 1-dimensional
linear vector. Rectangular or cubic shapes can’t be
direct inputs.
• We flatten the output of the convolution layers to
create a single long feature vector, which is connected
to the final classification model i.e fully-
connected layer.
Padding
• Padding is used in CNN to preserve the size of
feature maps.
• If we take a neural net with 100’s of layers, it will
give us a small image after filtered in the end. So
there are the two main downsides of applying
filters:
I. Shrinking outputs
II. Loosing information on corners of the image
Padding
• If we want to maintain the same dimensionality, we
use padding to surround the input with zeros.
………………………………..
Step 4
Step 9
Pooling
• Pooling layer is a building block of CNN. Its function
is to progressively reduce the size of representation
to reduce the amount of parameters and
computation in network.
• Pooling layer operates on each feature map
independently.
• Types of Pooling :
i. Max Pooling
ii. Average Pooling
Pooling
• Sliding a window, we only take the maximum value
inside the box on the left case. This is ‘max pooling.’
• We can also take the average values like the picture
on the right. This is ‘average pooling.’
Loss Layer
• Loss layer is a layer in CNN which calculates the
deviation between the predicted output and
calculated output.
Dense Layer
• A Dense layer is a regular layers of neurons in neural
network in which each neuron receives input from all
the neurons in previous layer.
• A densely connected layer provides learning features
from all the combinations of the inputs of previous
layers.
Dense layer
1 * 1 Convolution
• 1*1 Convolution simply means the filter is a size of
1*1. This 1*1 filter will convolve over the entire
input image pixel by pixel.
• A 1*1 Convolution maps an input pixels with all its
respective channels to an output pixel.
• 1*1 convolution is used for dimensionality
reduction in CNN.
• It reduces the size of the input vector, the number
of channels. The 1*1 convolutional layer is also
called a Pointwise Convolution.
• If we want to reduce the depth but keep the Height X Width of the
feature maps (Receptive field) the same, then we can choose 1X1
filters (where: Number of filters = Output Channels) to achieve this
effect.
• This effect of cross channel down-sampling is called ‘Dimensionality
reduction’.
Inception Network
• Inception Modules are used in Convolutional Neural
Networks to allow for more efficient computation and
deeper Networks through a dimensionality reduction with
stacked 1×1 convolutions.
Figure : Basic structure of Inception Network with multiple filters on same level
Using the bottleneck approaches we can rebuild the inception module
with less parameters. Also a max pooling layer is added to summarize
the content of the previous layer. All the results are concatenated one
after the other, and given to the next layer.
Versions of the Inception Network
Finds the direction that maximizes Finds the direction that maximizes
the variance in the data. the differences in the data.
Implementation of CNN like tensor flow,
keras etc.
Tensors