Deep 2
Deep 2
Module 2
DSE 5212
By: Dr.Rashmi L MALGHAN
Case Study:
Small Images : 10 classes
Example:
• We are using 60000 small images for classification. These images can be classified in one of the
10 categories below, classes =
["airplane","automobile","bird","cat","deer","dog","frog","horse","ship","truck"]
• CIFAR-10 and CIFAR-100 datasets
• Using ANN
• How to Install TensorFlow with GPU Support on Windows - Shawn Hymel
BENCHMARKING
(GPU ,CPU)
GPU bench-marking with image classification
To check Accuracy: Use evaluate function
12
PRECISION,
RECALL: FOR
DOG CLASS
13
PRECISION,
RECALL: FOR NOT
DOG CLASS
&
PRECISION
14
• True positive:
• 4 times I predicted truth as dog.
• 2 time I predicted truth as not dog.
• 3 time I predicted it as dog as it was not a
dog
• 1 time it was not a dog I predicted it to be
bot a dog.
• Anything in diagonal is all right
predictions.
15
DROPOUT
REGULARIZATION
Dropout Regularization
• Complex dataset will have many
hidden layers with lot of neurons init.
• So NN will try to overfit the dataset .
• So it will not perform well with test
dataset.
17
deep-learning-keras-tf-tutorial/13_dropout_layer at master · codebasics/deep-
learning-keras-tf-tutorial · GitHub
18
Drop Regularization
• In the dataset there is no column
nae so specified header=none.
• It uses integer sequence as
column names.
19
• Y has text data so
one hot encoding,
convert to int
20
ANN Building
21
22
Adding Dropout layer to model:
27
Over Sampling
Minority Class using
SMOTE
ENSEMBLE
LOSS
30
APPLICATIONS: IMBALANCE DATASETS
31
Applications:
Computer vision – DL
(CNN)
◦ Image classification, Video processing, Object
detection – Field – Computer Vision.
32
Banking & Agriculture
◦ Cheque Deposition.
◦ I take image of check , it will do image recognition, check number, cheque number. It will
automatically done by filling the information (Bank of America How to Deposit check on
mobile phone | Bank of America
◦ Detecting the apples on tree : To predict the yield. (“Product developers and technology
consultants: Cambridge Consultants”). AI and the future of agriculture
33
Why traditionally humans are better at image
recognition than computers?
Neural
Network
What is convolution operation and how it works
34
• Way how computer look at
this is grid of numbers. Here i
m considering it to be -1 and 1
representation.
• In reality it uses RGB number
Location Shift 0 to 255
35
Why not ANN?
◦ ANN works well for simple image
applications like handwritten digits.
◦ If for complex images ANN doesn’t
hold good.
◦ 24 million weights to be calculated
between input and hidden layers.
36
37
COMPARISON
TABLE
38
WHEN TO
USE
ANN V/S
CNN
39
How Does Human Recognize images : So Easily
40
How Does Human
Recognize images : So
Easily
◦ In human brain we use some neurons to
concentrate on tiny features.
◦ Different neurons to aggregate the results.
41
How can we make computers to learn these tiny
features:
◦ By using the concept of “filters”
42
Feature Mapping:
• We take original image, we apply convolution operation
• Feature Mapping is done: 3*3 gird data from original image gets mapped with 1st filter
(i.e. loop filter).
• Fetaure mapping: Multiply the original grid values with the filter value divide it by total
number of grid data we considered (i.e 9).
• Ex: (-1*1+1*1+1*1+-1*1+1*-1+-1*1+-1*1+1*1+1*1)/9 = -0.11
43
• Search for the value 1 or closer to 1.
• This is detecting feature. In case koala it might be eyes or nose by moving
the filter through out the image.
• Feature got activate where the value is close to 1 or 1.
44
Cases:
46
HANDS
DETECTOR
47
DIGIT
RECOGNITION
• In case of “9”: We
need to apply 3
filters (i.e. head,
middle & tail).
• we go three feature
maps.
48
Feature Map
Representation:
• In any articles or
books the Feature
Map is represented
like shown in figure
(its like stack
together).
49
• Filter Can be 3D.
• 1st slice may be representing : eyes, 2nd slice : nose, 3rd slice: ears.
• By doing that filter we can say that koala head is on the specific region (right side)
of an image.
• Aggregating different results (eyes, nose, ears) to get new feature map (head).
50
• Here it is different koala image.
• Thus it create different flatten array.
• NN handles variety: So it can handle variety input
51
• We use ReLU activation to bring the non-linearity in our model.
• It will take feature map and what ever negative values replace with “0”. Other values
keep it as it is.
• ReLU helps with making model non-linear: It makes bunch of values to be “0”
52
• For this image size if we are applying CNN with some padding we are still
getting same image size. Image size is Sometimes they don't use padding ,
they reduce image size but only little bit.
• So pooling is used to “reduce the size” 53
54
MAX
POOLING
56