SlideShare a Scribd company logo
Google Tech Sprint
Intro to CNN
By Vincent Tatan
Google Data Analyst (Machine Learning)
Wait, who am I?
Meet Vincent
Data Analyst (Machine Learning)
Trust & Safety Google
Medium : towardsdatascience.com/@vincentkernn
Linkedin : linkedin.com/in/vincenttatan/
Data Podcast: https://datacast.simplecast.com/
Disclaimer
This disclaimer informs readers that the views, thoughts, and opinions
expressed in the text belong solely to the author, and not necessarily to the
author’s employer, organization, committee or other group or individual.
This article was made purely as the author’s initiatives and in no way driven by
any other hidden agenda.
Path to Google
Visa
Business Intelligence Intern
May 16 - Jul 16
Lazada Group
Data Scientist Intern
Dec 16 - Apr 17B.Sc., Management Information
Systems and Services
Aug 13 - July 17
Visa
Data & Architecture
Engineer
Jun 17 - Aug 19
Google
Data Analyst, Machine
Learning
Aug 19 - Present
Google:
Trust and Safety To prevent phishing @
scale with Data Analytics
and ML
Google
Data Analyst, Machine Learning
Aug 19 - Present
Phishing Samples
Phishing Samples
Understanding CNN
Medium Articles
https://towardsdatascience.com/understanding-cnn-convolutional-neural-network-69fd626ee7d4
Colab Demonstration
Cat v.s. Dog using CNN
https://colab.sandbox.google.com/github/tensorflow/docs/blob/master/site/en/tutorials/images/classification.ipynb
Colab Demonstration
Cat v.s. Dog using CNN
https://colab.sandbox.google.com/github/tensorflow/docs/blob/master/site/en/tutorials/images/classification.ipynb
Proprietary + Confidential
Today’s Agenda
1
2
3
4
Machine Learning in Image Recognition
Principles behind CNN: Convolution, ReLU, Max Pooling
CNN stacks + Fully Connected Layer
Avoiding Overfitting + Transfer Learning
1
Machine Learning in Image
Recognition
Classify objects in images1
Image Recognition is hard -- Are all of these cats?
My search for the word “cat”.
Warning -- Not all of these are cats.
We need an automatic way to determine critical features to identify cats or other objects.
Black color
Sharp ears
We need a way to determine the features scalably
2 Principles behind CNN
Convolution, ReLU, Max Pooling
Introducing Convolutional Neural Network (CNN)
Type of neural network comprising of different layers of convolutions
and max pooling mainly for image recognition
1. Convolution
2. ReLU Activation
3. Max Pooling
Intuition of Convolutional Neural Network
What do you see?
Young lady or old grandma or
both?
Intuition of Convolutional Neural Network
Psychologist Edwin Boring
introduced the painting of “My Wife
and My Mother-in-Law” where the
figure seems to morph from young
lady to old woman, to the public in
1930. (Source)
These boxes determined the features of the object that you would classify.
● The curve that changed into (ears/eyes)
● The straight line that changed into (choker/mouth)
Intuition of Convolutional Neural Network
This means you are relying on
● Prior knowledge (your scrolling habits/understanding of faces)
● Data (strokes of the painting)
To identify Features
Intuition of Convolutional Neural Network
CNN distinguishes meaningful features from a sequence of
pixels rather than pixel per pixel to classify the image
1 1 1 1
0 0 1 1
0 1 0 1
1 1 1 1
0 0 0 0
1 1 1 1
1 1 1 1
0 0 0 0
Principle of CNN: Convolution (1-D)
Which order of the element where I see there is a change from 1 to 0?
[1,1,1,1,0,0]
Hint: answer is [0,0,0,1,0]
Principle of CNN: Convolution (1-D)
Which order of the element where I see 1 becomes -1?
1 -11 1 1 1 0 0
1st element : 1*1 + 1*-1 = 0
2nd element : 1*1 + 1*-1 = 0
3rd element : 1*1 + 1*-1 = 0
4th element : 1*1 + 0*-1 = 1
5th element : 0*1 + 0*-1 = 0
End Result: 0 0 0 1 0
Principle of CNN: Convolution (2-D)
Same principle also applies to 2-D where you derive the feature map using the kernels (acts as
weights in NN). With this kernel you can find diagonal patterns
>
Principle of CNN: Convolution (2-D), 3 stacks
Feature Maps
Principle of CNN: Activation Function ReLU
The ReLU function introduces non linearity to activate on a “big enough” stimulus (sparse
activation). This method has been effective to solve vanishing gradients due to its constant 1 for
weight more than 1. Weights that are very small will remain as 0 after the ReLU activation
function.
Principle of CNN: Maxpooling(2-D)
CNN uses max pooling to replace output with a max summary to reduce data size and
processing time. This allows you to determine features that produce the highest impact
and reduces the risk of overfitting.
Recap
Understanding CNN
1. Convolution
2. ReLU Activation Function
3. Maxpooling
3
CNN Stacks + Fully Connected
Layer
Generating Real Results
CNN Stacks + Fully Connected Layer(2-D)
Take the Feature maps from CNN as the inputs and insert it into NN models which will calculate the
probabilities of the image to the labels assigned.
Finally, we will serve the convolutional and max pooling feature map outputs with Fully Connected Layer
(FCL). We flatten the feature outputs to column vector and feed-forward it to FCL. Every node in the previous
layer is connected to the last layer and represents which distinct label to output. FCL represents Artificial
Neural Network and has the final layer as MultiLayer Perceptron (MLP)
CNN Stacks: Cats vs Dogs
The discovery of curves
Fully Connected Layer Activation: Softmax
softmax activation function squashes the probability scores to add up to 1.0.
CNN Big Picture: Cats vs Dogs
The sensors of the neural
network might start by
understanding what edges
and colors it is looking at.
The last layer, called the fully
connected layer,
summarizes this analysis and
gives the probability of
whether it is looking at a dog.
A third layer is trying to
conceptualize what these
shapes represent (for
instance, is it an animal or
something else?).
Another layer is trying to
understand what shapes it is
looking at.
Using Tensorflow + Keras
Create and Compile our CNN
Change to
‘categorical_crossentropy’ for
softmax
CNN Stacks
Fully Connected Layer
Train our CNN
Results: Cats vs Dogs
Results: Cats vs Dogs
Overfitting!
loss: 0.0134
acc: 0.9965
val_loss: 3.5137
val_acc: 0.7290
4
Avoiding Overfitting + Transfer
Learning
Improve Generalization and leverage pretrained
model
Overfitting Mistakes: CNN
Common Mistakes Solutions
Using test set as the validation set to test the
model
Use validation sets as validation tests and test
models as final tests
Dataset is relatively small Image augmentations to add new variants of
images
Over Memorization Dropout/ reduce epochs/layers/neurons per layer
to increase generalizations
Overfitting Solutions: Data Augmentation
In the case of small training data set, you need to artificially boost the diversity and number of training examples.
One way of doing this is to add image augmentations and creating new variants. These include translating
images and creating dimension changes such as zoom, crop, flips, etc.
Overfitting Solutions: Data Augmentation
Overfitting Solutions: Dropout
You could also use regularization techniques such as Dropout to remove activation unit in every gradient step training.
Each epoch training deactivates different neurons.
Since the number of gradient steps is usually high, all neurons will averagely have same occurrences for dropout.
Intuitively, the more you drop out, the less likely your model memorizes.
Overfitting Solutions: Dropout
Overfitting Solutions: Dropout
Results: Cats vs Dogs
Much better
loss: 0.5622
acc: 0.7145
val_loss: 0.5090
val_acc: 0.7650
Results: Cats vs Dogs
Overfitting CNN
CNN with Dropout and Image
Augmentation
loss: 0.5622
acc: 0.7145
val_loss: 0.5090
val_acc: 0.7650
loss: 0.0134
acc: 0.9965
val_loss: 3.5137
val_acc: 0.7290
Transfer Learning: ImageNet
Transfer learning is a technique that reuses an existing model to the current model. You could produce on top of existing models that were
carefully designed by experts and trained with millions of pictures. You can freeze the model, then only apply the training for the high level
layers.
Important Resources (Teachable Machine)
https://teachablemachine.withgoogle.com/train/image
Proprietary + Confidential
Today’s Summary
1
2
3
4
Machine Learning in Image Recognition
Principles behind CNN: Convolution, ReLU, Max Pooling
CNN stacks + Fully Connected Layer
Avoiding Overfitting + Transfer Learning
Proprietary + Confidential
Today’s Summary
Machine Learning in Image Recognition
Principles behind CNN: Convolution, ReLU, Max Pooling
CNN stacks + Fully Connected Layer
Transfer Learning
Avoiding Overfitting + Transfer Learning
04
● Data Augmentation: artificially boost diversity and number of training examples
● Dropout: Regularization Techniques to remove activation unit in every gradient
step training. Each epoch training deactivates different neurons.
● Transfer learning is a technique that reuses an existing model to the current
model. You could produce on top of existing models that were carefully
designed by experts and trained with millions of pictures.
CNN Stacks +Fully Connected Layer
03
● Fully Connected Layer: Take the Feature maps from CNN as the inputs and
insert it into NN models which will calculate the probabilities of the image to the
labels assigned.
● Softmax activation function which assign decimal probabilities for each
possible label which add up to 1.0.
Principles behind CNN: Convolution, ReLU, and
Max Pooling02
● Convolution: Same principle also applies to 2-D where you derive from the
feature map using the kernels (acts as weights in NN).
● The ReLU function introduces non linearity to activate on a “big enough”
stimulus (sparse activation).
● Max pooling to replace output with a max summary to reduce data size and
processing time.
Machine Learning in Image Recognition
01
● Classical Image Recognition Allows you to extract features and derive
characteristics.
● Convolution Neural Network (CNN) Deep learning techniques using
convolutions, max pooling to share weights, produce critical features, and
classify labels. Commonly used in image classifications
Colab Demonstration
Cat v.s. Dog using CNN
https://colab.sandbox.google.com/github/tensorflow/docs/blob/master/site/en/tutorials/images/classification.ipynb
Reach out to me :)
Medium : towardsdatascience.com/@vincentkernn
Linkedin : linkedin.com/in/vincenttatan/
Survey: tiny.cc/vincent-survey

More Related Content

PPTX
Dssg talk CNN intro
Vincent Tatan
 
PDF
Classification case study + intro to cnn
Vincent Tatan
 
PPTX
Introduction to ml ops in daily apps
Vincent Tatan
 
PDF
Using Deep Learning to Find Similar Dresses
HJ van Veen
 
PDF
Data Science - Part IX - Support Vector Machine
Derek Kane
 
PPTX
Mnist report ppt
RaghunandanJairam
 
PDF
MNIST and machine learning - presentation
Steve Dias da Cruz
 
PPTX
Diving into Deep Learning (Silicon Valley Code Camp 2017)
Oswald Campesato
 
Dssg talk CNN intro
Vincent Tatan
 
Classification case study + intro to cnn
Vincent Tatan
 
Introduction to ml ops in daily apps
Vincent Tatan
 
Using Deep Learning to Find Similar Dresses
HJ van Veen
 
Data Science - Part IX - Support Vector Machine
Derek Kane
 
Mnist report ppt
RaghunandanJairam
 
MNIST and machine learning - presentation
Steve Dias da Cruz
 
Diving into Deep Learning (Silicon Valley Code Camp 2017)
Oswald Campesato
 

What's hot (20)

PDF
Variants of GANs - Jaejun Yoo
JaeJun Yoo
 
PPTX
Machine learning and vulnerabilities
galazzo
 
PDF
Deep learning-practical
Hitesh Mohapatra
 
PPTX
Introduction to Deep Learning and Tensorflow
Oswald Campesato
 
PPTX
sentiment analysis using support vector machine
Shital Andhale
 
PPTX
Java and Deep Learning
Oswald Campesato
 
PPT
Svm ms
student
 
PDF
Matrix Factorization In Recommender Systems
YONG ZHENG
 
PDF
“Introducing Machine Learning and How to Teach Machines to See,” a Presentati...
Edge AI and Vision Alliance
 
PDF
Prediction of Exchange Rate Using Deep Neural Network
Tomoki Hayashi
 
PPTX
Learn to Build an App to Find Similar Images using Deep Learning- Piotr Teterwak
PyData
 
PDF
Deep learning (Machine learning) tutorial for beginners
Terry Taewoong Um
 
PDF
Camp IT: Making the World More Efficient Using AI & Machine Learning
Krzysztof Kowalczyk
 
PDF
DL Classe 1 - Go Deep or Go Home
Gregory Renard
 
PDF
Deep Learning Class #1 - Go Deep or Go Home
Holberton School
 
PDF
MATLAB Code + Description : Real-Time Object Motion Detection and Tracking
Ahmed Gad
 
PPTX
Session-Based Recommendations with Recurrent Neural Networks (Balazs Hidasi, ...
hyunsung lee
 
DOC
SVM Tutorial
butest
 
PDF
Deeplearning in finance
Sebastien Jehan
 
PDF
Generative Models and Adversarial Training (D2L3 Insight@DCU Machine Learning...
Universitat Politècnica de Catalunya
 
Variants of GANs - Jaejun Yoo
JaeJun Yoo
 
Machine learning and vulnerabilities
galazzo
 
Deep learning-practical
Hitesh Mohapatra
 
Introduction to Deep Learning and Tensorflow
Oswald Campesato
 
sentiment analysis using support vector machine
Shital Andhale
 
Java and Deep Learning
Oswald Campesato
 
Svm ms
student
 
Matrix Factorization In Recommender Systems
YONG ZHENG
 
“Introducing Machine Learning and How to Teach Machines to See,” a Presentati...
Edge AI and Vision Alliance
 
Prediction of Exchange Rate Using Deep Neural Network
Tomoki Hayashi
 
Learn to Build an App to Find Similar Images using Deep Learning- Piotr Teterwak
PyData
 
Deep learning (Machine learning) tutorial for beginners
Terry Taewoong Um
 
Camp IT: Making the World More Efficient Using AI & Machine Learning
Krzysztof Kowalczyk
 
DL Classe 1 - Go Deep or Go Home
Gregory Renard
 
Deep Learning Class #1 - Go Deep or Go Home
Holberton School
 
MATLAB Code + Description : Real-Time Object Motion Detection and Tracking
Ahmed Gad
 
Session-Based Recommendations with Recurrent Neural Networks (Balazs Hidasi, ...
hyunsung lee
 
SVM Tutorial
butest
 
Deeplearning in finance
Sebastien Jehan
 
Generative Models and Adversarial Training (D2L3 Insight@DCU Machine Learning...
Universitat Politècnica de Catalunya
 
Ad

Similar to [Revised] Intro to CNN (20)

PPTX
Deep learning
Aman Kamboj
 
PPTX
Ultrasound Nerve Segmentation
Sneha Ravikumar
 
DOCX
Deep Neural Network DNN.docx
jaffarbikat
 
PDF
Integrating Artificial Intelligence with IoT
bplay2086
 
PPTX
Helmet_Detection .pptx
habibfatimazahra6
 
PDF
AI and Deep Learning
Subrat Panda, PhD
 
PDF
Model Evaluation in the land of Deep Learning
Pramit Choudhary
 
PDF
Deep Learning Demystified
Affine Analytics
 
PPTX
Image captioning
Muhammad Zbeedat
 
PPTX
cnn ppt.pptx
rohithprabhas1
 
PDF
Human Emotion Recognition
Chaitanya Maddala
 
PDF
IRJET-Multiclass Classification Method Based On Deep Learning For Leaf Identi...
IRJET Journal
 
PPTX
Introduction to Convolutional Neural Networks
ParrotAI
 
PPTX
Android and Deep Learning
Oswald Campesato
 
DOCX
Course Title CS591-Advance Artificial Intelligence
CruzIbarra161
 
PPTX
Deeplearning for Computer Vision PPT with
naveenraghavendran10
 
PDF
Fake News Detection using Deep Learning
NIET Journal of Engineering & Technology (NIETJET)
 
PPTX
Deep Computer Vision - 1.pptx
JawadHaider36
 
PPTX
Convolution Neural Network (CNN)
Suraj Aavula
 
PPTX
computervisionanditsapplications-190311134821.pptx
OrxanMirzzad
 
Deep learning
Aman Kamboj
 
Ultrasound Nerve Segmentation
Sneha Ravikumar
 
Deep Neural Network DNN.docx
jaffarbikat
 
Integrating Artificial Intelligence with IoT
bplay2086
 
Helmet_Detection .pptx
habibfatimazahra6
 
AI and Deep Learning
Subrat Panda, PhD
 
Model Evaluation in the land of Deep Learning
Pramit Choudhary
 
Deep Learning Demystified
Affine Analytics
 
Image captioning
Muhammad Zbeedat
 
cnn ppt.pptx
rohithprabhas1
 
Human Emotion Recognition
Chaitanya Maddala
 
IRJET-Multiclass Classification Method Based On Deep Learning For Leaf Identi...
IRJET Journal
 
Introduction to Convolutional Neural Networks
ParrotAI
 
Android and Deep Learning
Oswald Campesato
 
Course Title CS591-Advance Artificial Intelligence
CruzIbarra161
 
Deeplearning for Computer Vision PPT with
naveenraghavendran10
 
Fake News Detection using Deep Learning
NIET Journal of Engineering & Technology (NIETJET)
 
Deep Computer Vision - 1.pptx
JawadHaider36
 
Convolution Neural Network (CNN)
Suraj Aavula
 
computervisionanditsapplications-190311134821.pptx
OrxanMirzzad
 
Ad

More from Vincent Tatan (7)

PPTX
Life of a ML Engineer [Redacted].pptx
Vincent Tatan
 
PPTX
[Master] unboxing design docs for data scientists
Vincent Tatan
 
PPTX
Listen, check, and pay
Vincent Tatan
 
PPTX
Intro to ml lesson vincent
Vincent Tatan
 
PPTX
Overcoming Imposter Syndrome
Vincent Tatan
 
PPTX
SAS Slides FINALE (2)
Vincent Tatan
 
PDF
Doc 14 Jan 2016%2c 1014-rotated (1)
Vincent Tatan
 
Life of a ML Engineer [Redacted].pptx
Vincent Tatan
 
[Master] unboxing design docs for data scientists
Vincent Tatan
 
Listen, check, and pay
Vincent Tatan
 
Intro to ml lesson vincent
Vincent Tatan
 
Overcoming Imposter Syndrome
Vincent Tatan
 
SAS Slides FINALE (2)
Vincent Tatan
 
Doc 14 Jan 2016%2c 1014-rotated (1)
Vincent Tatan
 

Recently uploaded (20)

PDF
Key_Statistical_Techniques_in_Analytics_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
PPTX
White Blue Simple Modern Enhancing Sales Strategy Presentation_20250724_21093...
RamNeymarjr
 
PPTX
INFO8116 - Week 10 - Slides.pptx big data architecture
guddipatel10
 
PDF
Company Presentation pada Perusahaan ADB.pdf
didikfahmi
 
PPT
Grade 5 PPT_Science_Q2_W6_Methods of reproduction.ppt
AaronBaluyut
 
PPTX
short term project on AI Driven Data Analytics
JMJCollegeComputerde
 
PPTX
The whitetiger novel review for collegeassignment.pptx
DhruvPatel754154
 
PPTX
Presentation (1) (1).pptx k8hhfftuiiigff
karthikjagath2005
 
PPTX
Fuzzy_Membership_Functions_Presentation.pptx
pythoncrazy2024
 
PDF
Research about a FoodFolio app for personalized dietary tracking and health o...
AustinLiamAndres
 
PPTX
Complete_STATA_Introduction_Beginner.pptx
mbayekebe
 
PDF
Practical Measurement Systems Analysis (Gage R&R) for design
Rob Schubert
 
PDF
Classifcation using Machine Learning and deep learning
bhaveshagrawal35
 
PPTX
Blue and Dark Blue Modern Technology Presentation.pptx
ap177979
 
PPTX
Web dev -ppt that helps us understand web technology
shubhragoyal12
 
PPTX
Data-Driven Machine Learning for Rail Infrastructure Health Monitoring
Sione Palu
 
PDF
202501214233242351219 QASS Session 2.pdf
lauramejiamillan
 
PDF
D9110.pdfdsfvsdfvsdfvsdfvfvfsvfsvffsdfvsdfvsd
minhn6673
 
PPTX
Introduction-to-Python-Programming-Language (1).pptx
dhyeysapariya
 
PPTX
INFO8116 - Week 10 - Slides.pptx data analutics
guddipatel10
 
Key_Statistical_Techniques_in_Analytics_by_CA_Suvidha_Chaplot.pdf
CA Suvidha Chaplot
 
White Blue Simple Modern Enhancing Sales Strategy Presentation_20250724_21093...
RamNeymarjr
 
INFO8116 - Week 10 - Slides.pptx big data architecture
guddipatel10
 
Company Presentation pada Perusahaan ADB.pdf
didikfahmi
 
Grade 5 PPT_Science_Q2_W6_Methods of reproduction.ppt
AaronBaluyut
 
short term project on AI Driven Data Analytics
JMJCollegeComputerde
 
The whitetiger novel review for collegeassignment.pptx
DhruvPatel754154
 
Presentation (1) (1).pptx k8hhfftuiiigff
karthikjagath2005
 
Fuzzy_Membership_Functions_Presentation.pptx
pythoncrazy2024
 
Research about a FoodFolio app for personalized dietary tracking and health o...
AustinLiamAndres
 
Complete_STATA_Introduction_Beginner.pptx
mbayekebe
 
Practical Measurement Systems Analysis (Gage R&R) for design
Rob Schubert
 
Classifcation using Machine Learning and deep learning
bhaveshagrawal35
 
Blue and Dark Blue Modern Technology Presentation.pptx
ap177979
 
Web dev -ppt that helps us understand web technology
shubhragoyal12
 
Data-Driven Machine Learning for Rail Infrastructure Health Monitoring
Sione Palu
 
202501214233242351219 QASS Session 2.pdf
lauramejiamillan
 
D9110.pdfdsfvsdfvsdfvsdfvfvfsvfsvffsdfvsdfvsd
minhn6673
 
Introduction-to-Python-Programming-Language (1).pptx
dhyeysapariya
 
INFO8116 - Week 10 - Slides.pptx data analutics
guddipatel10
 

[Revised] Intro to CNN

  • 1. Google Tech Sprint Intro to CNN By Vincent Tatan Google Data Analyst (Machine Learning)
  • 3. Meet Vincent Data Analyst (Machine Learning) Trust & Safety Google Medium : towardsdatascience.com/@vincentkernn Linkedin : linkedin.com/in/vincenttatan/ Data Podcast: https://datacast.simplecast.com/
  • 4. Disclaimer This disclaimer informs readers that the views, thoughts, and opinions expressed in the text belong solely to the author, and not necessarily to the author’s employer, organization, committee or other group or individual. This article was made purely as the author’s initiatives and in no way driven by any other hidden agenda.
  • 5. Path to Google Visa Business Intelligence Intern May 16 - Jul 16 Lazada Group Data Scientist Intern Dec 16 - Apr 17B.Sc., Management Information Systems and Services Aug 13 - July 17 Visa Data & Architecture Engineer Jun 17 - Aug 19 Google Data Analyst, Machine Learning Aug 19 - Present
  • 6. Google: Trust and Safety To prevent phishing @ scale with Data Analytics and ML Google Data Analyst, Machine Learning Aug 19 - Present
  • 10. Colab Demonstration Cat v.s. Dog using CNN https://colab.sandbox.google.com/github/tensorflow/docs/blob/master/site/en/tutorials/images/classification.ipynb
  • 11. Colab Demonstration Cat v.s. Dog using CNN https://colab.sandbox.google.com/github/tensorflow/docs/blob/master/site/en/tutorials/images/classification.ipynb
  • 12. Proprietary + Confidential Today’s Agenda 1 2 3 4 Machine Learning in Image Recognition Principles behind CNN: Convolution, ReLU, Max Pooling CNN stacks + Fully Connected Layer Avoiding Overfitting + Transfer Learning
  • 13. 1 Machine Learning in Image Recognition Classify objects in images1
  • 14. Image Recognition is hard -- Are all of these cats? My search for the word “cat”.
  • 15. Warning -- Not all of these are cats. We need an automatic way to determine critical features to identify cats or other objects. Black color Sharp ears
  • 16. We need a way to determine the features scalably
  • 17. 2 Principles behind CNN Convolution, ReLU, Max Pooling
  • 18. Introducing Convolutional Neural Network (CNN) Type of neural network comprising of different layers of convolutions and max pooling mainly for image recognition 1. Convolution 2. ReLU Activation 3. Max Pooling
  • 19. Intuition of Convolutional Neural Network What do you see? Young lady or old grandma or both?
  • 20. Intuition of Convolutional Neural Network Psychologist Edwin Boring introduced the painting of “My Wife and My Mother-in-Law” where the figure seems to morph from young lady to old woman, to the public in 1930. (Source) These boxes determined the features of the object that you would classify. ● The curve that changed into (ears/eyes) ● The straight line that changed into (choker/mouth)
  • 21. Intuition of Convolutional Neural Network This means you are relying on ● Prior knowledge (your scrolling habits/understanding of faces) ● Data (strokes of the painting) To identify Features
  • 22. Intuition of Convolutional Neural Network CNN distinguishes meaningful features from a sequence of pixels rather than pixel per pixel to classify the image 1 1 1 1 0 0 1 1 0 1 0 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1 1 1 0 0 0 0
  • 23. Principle of CNN: Convolution (1-D) Which order of the element where I see there is a change from 1 to 0? [1,1,1,1,0,0] Hint: answer is [0,0,0,1,0]
  • 24. Principle of CNN: Convolution (1-D) Which order of the element where I see 1 becomes -1? 1 -11 1 1 1 0 0 1st element : 1*1 + 1*-1 = 0 2nd element : 1*1 + 1*-1 = 0 3rd element : 1*1 + 1*-1 = 0 4th element : 1*1 + 0*-1 = 1 5th element : 0*1 + 0*-1 = 0 End Result: 0 0 0 1 0
  • 25. Principle of CNN: Convolution (2-D) Same principle also applies to 2-D where you derive the feature map using the kernels (acts as weights in NN). With this kernel you can find diagonal patterns >
  • 26. Principle of CNN: Convolution (2-D), 3 stacks Feature Maps
  • 27. Principle of CNN: Activation Function ReLU The ReLU function introduces non linearity to activate on a “big enough” stimulus (sparse activation). This method has been effective to solve vanishing gradients due to its constant 1 for weight more than 1. Weights that are very small will remain as 0 after the ReLU activation function.
  • 28. Principle of CNN: Maxpooling(2-D) CNN uses max pooling to replace output with a max summary to reduce data size and processing time. This allows you to determine features that produce the highest impact and reduces the risk of overfitting.
  • 29. Recap Understanding CNN 1. Convolution 2. ReLU Activation Function 3. Maxpooling
  • 30. 3 CNN Stacks + Fully Connected Layer Generating Real Results
  • 31. CNN Stacks + Fully Connected Layer(2-D) Take the Feature maps from CNN as the inputs and insert it into NN models which will calculate the probabilities of the image to the labels assigned. Finally, we will serve the convolutional and max pooling feature map outputs with Fully Connected Layer (FCL). We flatten the feature outputs to column vector and feed-forward it to FCL. Every node in the previous layer is connected to the last layer and represents which distinct label to output. FCL represents Artificial Neural Network and has the final layer as MultiLayer Perceptron (MLP)
  • 32. CNN Stacks: Cats vs Dogs The discovery of curves
  • 33. Fully Connected Layer Activation: Softmax softmax activation function squashes the probability scores to add up to 1.0.
  • 34. CNN Big Picture: Cats vs Dogs The sensors of the neural network might start by understanding what edges and colors it is looking at. The last layer, called the fully connected layer, summarizes this analysis and gives the probability of whether it is looking at a dog. A third layer is trying to conceptualize what these shapes represent (for instance, is it an animal or something else?). Another layer is trying to understand what shapes it is looking at.
  • 36. Create and Compile our CNN Change to ‘categorical_crossentropy’ for softmax CNN Stacks Fully Connected Layer
  • 39. Results: Cats vs Dogs Overfitting! loss: 0.0134 acc: 0.9965 val_loss: 3.5137 val_acc: 0.7290
  • 40. 4 Avoiding Overfitting + Transfer Learning Improve Generalization and leverage pretrained model
  • 41. Overfitting Mistakes: CNN Common Mistakes Solutions Using test set as the validation set to test the model Use validation sets as validation tests and test models as final tests Dataset is relatively small Image augmentations to add new variants of images Over Memorization Dropout/ reduce epochs/layers/neurons per layer to increase generalizations
  • 42. Overfitting Solutions: Data Augmentation In the case of small training data set, you need to artificially boost the diversity and number of training examples. One way of doing this is to add image augmentations and creating new variants. These include translating images and creating dimension changes such as zoom, crop, flips, etc.
  • 44. Overfitting Solutions: Dropout You could also use regularization techniques such as Dropout to remove activation unit in every gradient step training. Each epoch training deactivates different neurons. Since the number of gradient steps is usually high, all neurons will averagely have same occurrences for dropout. Intuitively, the more you drop out, the less likely your model memorizes.
  • 47. Results: Cats vs Dogs Much better loss: 0.5622 acc: 0.7145 val_loss: 0.5090 val_acc: 0.7650
  • 48. Results: Cats vs Dogs Overfitting CNN CNN with Dropout and Image Augmentation loss: 0.5622 acc: 0.7145 val_loss: 0.5090 val_acc: 0.7650 loss: 0.0134 acc: 0.9965 val_loss: 3.5137 val_acc: 0.7290
  • 49. Transfer Learning: ImageNet Transfer learning is a technique that reuses an existing model to the current model. You could produce on top of existing models that were carefully designed by experts and trained with millions of pictures. You can freeze the model, then only apply the training for the high level layers.
  • 50. Important Resources (Teachable Machine) https://teachablemachine.withgoogle.com/train/image
  • 51. Proprietary + Confidential Today’s Summary 1 2 3 4 Machine Learning in Image Recognition Principles behind CNN: Convolution, ReLU, Max Pooling CNN stacks + Fully Connected Layer Avoiding Overfitting + Transfer Learning
  • 52. Proprietary + Confidential Today’s Summary Machine Learning in Image Recognition Principles behind CNN: Convolution, ReLU, Max Pooling CNN stacks + Fully Connected Layer Transfer Learning Avoiding Overfitting + Transfer Learning 04 ● Data Augmentation: artificially boost diversity and number of training examples ● Dropout: Regularization Techniques to remove activation unit in every gradient step training. Each epoch training deactivates different neurons. ● Transfer learning is a technique that reuses an existing model to the current model. You could produce on top of existing models that were carefully designed by experts and trained with millions of pictures. CNN Stacks +Fully Connected Layer 03 ● Fully Connected Layer: Take the Feature maps from CNN as the inputs and insert it into NN models which will calculate the probabilities of the image to the labels assigned. ● Softmax activation function which assign decimal probabilities for each possible label which add up to 1.0. Principles behind CNN: Convolution, ReLU, and Max Pooling02 ● Convolution: Same principle also applies to 2-D where you derive from the feature map using the kernels (acts as weights in NN). ● The ReLU function introduces non linearity to activate on a “big enough” stimulus (sparse activation). ● Max pooling to replace output with a max summary to reduce data size and processing time. Machine Learning in Image Recognition 01 ● Classical Image Recognition Allows you to extract features and derive characteristics. ● Convolution Neural Network (CNN) Deep learning techniques using convolutions, max pooling to share weights, produce critical features, and classify labels. Commonly used in image classifications
  • 53. Colab Demonstration Cat v.s. Dog using CNN https://colab.sandbox.google.com/github/tensorflow/docs/blob/master/site/en/tutorials/images/classification.ipynb
  • 54. Reach out to me :) Medium : towardsdatascience.com/@vincentkernn Linkedin : linkedin.com/in/vincenttatan/ Survey: tiny.cc/vincent-survey