CSE4261 Lecture-11
CSE4261 Lecture-11
Neural Networks(CNN)
5
Padding
• Sometimes, when dealing with images, getting a result from a
convolution operation with dimensions different from the original
image is not optimal. This is when padding is necessary.
• Add rows of pixels on the top and bottom and columns of pixels on
the right and left of the final images so the resulting matrices are the
same size as the original.
Building Blocks of a CNN
• Convolution and pooling operations are used to
build the layers in CNNs.
Why 1 is here?
What is Dropout?
What is Flatten?
Dropout Regularization Techniques
• Dropout is a technique where randomly selected
neurons are ignored during training. They are
“dropped out” randomly. This means that their
contribution to the activation of downstream neurons
is temporally removed on the forward pass, and
weight updates are not applied to the neuron on the
backward pass.
• Generally, use a small dropout value of 20%-50% of
neurons with 20% providing a good starting point. A
low probability has minimal effect and a high value
results in under-learning by the network.
Flatten Layer
• Intuition behind flattening layer is to converts data
into 1-dimentional array for feeding next layer. we
flatted output of convolutional layer into single long
feature vector.
FC and Dense Layer
• A fully-connected layer is a layer that has a
connection/edge across every pair of nodes from two
node sets. For example, if you want to build a layer
with N1 input neurons and N2 output neurons, the
number of connections/edges will be N1 X N2, which is
also the shape of the weight matrix.
• As the number of connections can be very large (think
of connecting thousands of neurons to one another),
the layer is going to be highly dense which is why these
layers are also called Dense Layer.
4608
32x5x5
S=1 2x2
32x12x12
4608x128+128
128x10+10
Effect of
Convolution
Effect of Max
Pooling
Going Deeper with Convolutions
1x1
3x3 5x5
32+32 32x9x32+32 Reduce channel to kernel
32x25x32+32
dimension
Inception Module: Dimension Reduction
• In the naïve inception module, we get a smaller number of learnable parameters
concerning classical CNNs, but we can do even better
• We can use 1 × 1
convolutions at the right
places (mainly before the 8 kernels
higher dimension 8 kernels
convolutions) to reduce
dimensions. 8 kernels 8 kernels
• Suppose that the previous
layer is the output of a
previous operation and that
its output has the
dimensions of 256, 28, 28.
Models # of Parameters
Naïve Inception 256x1x8+8=2056, 256x9x8+8=18,440, 256x25x8+8=51,208
Total=71,704
Parallel Processing 2056, (2056+8x9x8+8=2056+584=2640),
(2056+8x25x8+8=2056+1608=3664), 2056
Total=10,416 [An inception network is simply built by stacking lots of those
modules one after the other]
GoogLeNet: Multiple Cost Functions
• Stacks several inception models one after the other
– the middle layers tend to “die”.
• If you use the value imagenet, the weights are the ones
obtained by training the network with the imagenet
dataset
Transfer Learning
• Transfer learning is a technique where a model trained to
solve a specific problem is re-purposed for a new
challenge related to the first problem.
• The imagenet dataset can be used to classify dogs’
images but should not be used for speech recognition.
With two epochs, 69% validation accuracy and 70% training accuracy.
A Dog and Cat Problem
Transfer Learning Approach 1
100 epochs??