SlideShare a Scribd company logo
1 of 48
Download to read offline
Convolutional
Neural Networks
For Image Classification
Alex Conway
alex @ numberboost.com
Cape Town Deep Learning Meet-up 20 June 2017
https://github.com/alexcnwy/CTDL_CNN_TALK_20170620
Hands up!
Big Shout Outs
Jeremy Howard & Rachel Thomas
http://course.fast.ai
Andrej Karpathy
http://cs231n.github.io
4
1. What is a neural network?
2. What is an image?
3. What is a convolutional neural network?
4. Using a pre-trained ImageNet-winning CNN
5. Fine-tuning a CNN to solve a new problem
6. Visual similarity “latest AI technology” app
7. Practical tips
8. Image cropping
9. Image captioning
10. CNN + Word2Vec
11. Style transfer
12. Where to from here?
5
1. What is a neural network?
2. What is an image?
3. What is a convolutional neural network?
4. Using a pre-trained ImageNet-winning CNN
5. Fine-tuning a CNN to solve a new problem
6. Visual similarity “latest AI technology” app
7. Practical tips
8. Image cropping
9. Image captioning
10. CNN + Word2Vec
11. Style transfer
12. Where to from here?
6
What is a Neural Network?
7
What is a Neural Network?
8
What is a Neural Network?
9
http://playground.tensorflow.org
What is a Neural Network?
For much more detail, see:
1. Michael Nielson’s Neural Networks & Deep
Learning free online book
http://neuralnetworksanddeeplearning.com/chap1.html
2. Anrej Karpathy’s CS231n Notes
http://neuralnetworksanddeeplearning.com/chap1.html
11
What is a Neural Network?
Universal
Approximation
theorem:
http://neuralnetworksanddeeplearning.com/chap4.html 12
What is an Image?
• Pixel = 3 colour channels (R, G, B)
• Pixel intensity = number in [0,255]
• Image has width w and height h
• Therefore image is w x h x 3 numbers
13
What is a Convolutional Neural Network (CNN)?
CNN = Neural Network + Image
- with some tricks -
14
What is a Convolutional Neural Network (CNN)?
15
Convolutions
16
• 2-d weighted average
• Element-wise multiply kernel with pixels
• “learn” the kernels
• http://setosa.io/ev/image-kernels/
• http://cs231n.github.io/convolutional-networks/
Convolutions
17
“imagine taking this 3x3 matrix (“kernel”) and positioning
it over a 3x3 area of an image, and let's multiply each
overlapping value. Next, let's sum up these products, and
let's replace the center pixel with this new value. If we
slide this 3x3 matrix over the entire image, we can
construct a new image by replacing each pixel in the
same manner just described.”
Convolutions
18
“...we understand that filters can be used to identify
particular visual "elements" of an image, it's easy to see
why they're used in deep learning for image recognition.
But how do we decide which kinds of filters are the most
effective? Specifically, what filters are best at capturing
the necessary detail from our image to classify it?
• …these filters are just matrices that we are applying to
our input to achieve a desired output... therefore, given
labelled input, we don't need to manually decide what
filters work best at classifying our images, we can simply
train a model to do so, using these filters as weights!
Convolutions
19
“ ...for example, we can start with 8 randomly
generated filters; that is 8 3x3 matrices with random
elements. Given labeled inputs, we can then use
stochastic gradient descent to determine what the
optimal values of these filters are, and therefore we
allow the neural network to learn what things are
most important to detect in classifying images. “
Convolutions
20
Convolutions
21
Convolutions
22
Convolutions
23
Max Pooling
• Reduces dimensionality from one layer to next
• By replacing NxN sub-area with max value
• Makes network “look” at larger areas of the image at a
time e.g. Instead of identifying fur, identify cat
• Reduces computational load
• Controls for overfitting
24
Dropout
• Form of regularization (helps prevent overfitting)
• Trades ability to fit training data to help generalize to new data
• Used during training (not test)
• Randomly set weights in hidden layers to 0 with some probability p
25
CNN Architectures
xxx
26
Using a Pre-Trained ImageNet-Winning CNN
27
http://image-net.org/explore
Using a Pre-Trained ImageNet-Winning CNN
28
Using a Pre-Trained ImageNet-Winning CNN
29
• We’ll be using “VGGNet”
• Oxford Visual Geometry Group (VGG)
• The runner-up in ILSVRC 2014
• Network contains 16 CONV/FC layers (deep!)
• The whole VGGNet is composed of CONV layers that perform
3x3 convolutions with stride 1 and pad 1, and of POOL layers
that perform 2x2 max pooling with stride 2 (and no padding)
• Its main contribution was in showing that the depth of the
network is a critical component for good performance.
• Homogeneous architecture that only performs 3x3
convolutions and 2x2 pooling from the beginning to the end.
• Easy to fine-tune
Using a Pre-Trained ImageNet-Winning CNN
30
Using a Pre-Trained ImageNet-Winning CNN
31
CODE TIME!
https://github.com/alexcnwy/CTDL_CNN_TALK_20170620
Fine-tuning A CNN To Solve A New Problem
• Fix weights in convolutional layers (trainable=False)
• Re-train final dense layer(s)
32
CODE TIME!
https://github.com/alexcnwy/CTDL_CNN_TALK_20170620
Visual Similarity “Latest AI Technology” App
33
https://memeburn.com/2017/06/spree-image-search/
Visual Similarity “Latest AI Technology” App
34
CODE TIME!
• Chop off last 2 layers
• Use dense layer with 4096 activations
• Compute nearest neighbours in the space of these
activations
https://github.com/alexcnwy/CTDL_CNN_TALK_20170620
Practical Tips
• use a GPU – AWS p2 instances not that expensive – much faster
• use “adam” / different optimizers SGD variants
– http://sebastianruder.com/content/images/2016/09/saddle_point_evaluation_optimizers.gif
• look at nvidia-smi
• when overfitting - try lower dropout and train longer
• when underfitting, try:
1. Add more data
2. Use data augmentation
– flipping
– slightly changing hues
– stretching
– shearing
– rotation
3. Use more complicated architecture (Resnets, Inception, etc)
35
Pseudo Labelling
36
Pseudo Labelling
37
Pseudo Labelling
38
Image Cropping
Label the
bounding
boxes
Learn to
predict them
Just extra
input to CNN
39
Image Captioning
XXX
40
CNN + Word2Vec
41
CNN + Word2Vec
42
CNN + Word2Vec
43
CNN + Word2Vec
44
CNN + Word2Vec
45
• Learn the word2vec vectors for each ImangeNet noun
Style Transfer
• http://blog.romanofoti.com/style_transfer/
• https://github.com/junyanz/CycleGAN
46
Where to From Here?
• Clone the repo and train your own model
• Do the fast.ai course
• Read the cs231n notes
• Read http://colah.github.io/posts
• Email me questions /ideas :)
alex@numberboost.com
47
THANKS!
https://github.com/alexcnwy/CTDL_CNN_TALK_20170620
Alex Conway
alex @ numberboost.com

More Related Content

What's hot

Image Classification with Deep Learning | DevFest + GDay, George Town, Mala...
Image Classification with Deep Learning  |  DevFest + GDay, George Town, Mala...Image Classification with Deep Learning  |  DevFest + GDay, George Town, Mala...
Image Classification with Deep Learning | DevFest + GDay, George Town, Mala...Virot "Ta" Chiraphadhanakul
 
PyConZA 2019 Keynote - Deep Neural Networks for Video Applications
PyConZA 2019 Keynote - Deep Neural Networks for Video ApplicationsPyConZA 2019 Keynote - Deep Neural Networks for Video Applications
PyConZA 2019 Keynote - Deep Neural Networks for Video ApplicationsAlex Conway
 
Deep Learning in Computer Vision
Deep Learning in Computer VisionDeep Learning in Computer Vision
Deep Learning in Computer VisionSungjoon Choi
 
ujava.org Deep Learning with Convolutional Neural Network
ujava.org Deep Learning with Convolutional Neural Network ujava.org Deep Learning with Convolutional Neural Network
ujava.org Deep Learning with Convolutional Neural Network 신동 강
 
Image Classification using deep learning
Image Classification using deep learning Image Classification using deep learning
Image Classification using deep learning Asma-AH
 
Convolutional Neural Network (CNN) - image recognition
Convolutional Neural Network (CNN)  - image recognitionConvolutional Neural Network (CNN)  - image recognition
Convolutional Neural Network (CNN) - image recognitionYUNG-KUEI CHEN
 
Deep Learning behind Prisma
Deep Learning behind PrismaDeep Learning behind Prisma
Deep Learning behind Prismalostleaves
 
Applied Deep Learning 11/03 Convolutional Neural Networks
Applied Deep Learning 11/03 Convolutional Neural NetworksApplied Deep Learning 11/03 Convolutional Neural Networks
Applied Deep Learning 11/03 Convolutional Neural NetworksMark Chang
 
Deep Learning Tutorial
Deep Learning Tutorial Deep Learning Tutorial
Deep Learning Tutorial Ligeng Zhu
 
Diving into Deep Learning (Silicon Valley Code Camp 2017)
Diving into Deep Learning (Silicon Valley Code Camp 2017)Diving into Deep Learning (Silicon Valley Code Camp 2017)
Diving into Deep Learning (Silicon Valley Code Camp 2017)Oswald Campesato
 
DRAW: Deep Recurrent Attentive Writer
DRAW: Deep Recurrent Attentive WriterDRAW: Deep Recurrent Attentive Writer
DRAW: Deep Recurrent Attentive WriterMark Chang
 
Image classification using cnn
Image classification using cnnImage classification using cnn
Image classification using cnnDebarko De
 
Deep Learning - CNN and RNN
Deep Learning - CNN and RNNDeep Learning - CNN and RNN
Deep Learning - CNN and RNNAshray Bhandare
 
Modern Convolutional Neural Network techniques for image segmentation
Modern Convolutional Neural Network techniques for image segmentationModern Convolutional Neural Network techniques for image segmentation
Modern Convolutional Neural Network techniques for image segmentationGioele Ciaparrone
 
AlexNet(ImageNet Classification with Deep Convolutional Neural Networks)
AlexNet(ImageNet Classification with Deep Convolutional Neural Networks)AlexNet(ImageNet Classification with Deep Convolutional Neural Networks)
AlexNet(ImageNet Classification with Deep Convolutional Neural Networks)Fellowship at Vodafone FutureLab
 
RNN and its applications
RNN and its applicationsRNN and its applications
RNN and its applicationsSungjoon Choi
 
TensorFlow Tutorial Part2
TensorFlow Tutorial Part2TensorFlow Tutorial Part2
TensorFlow Tutorial Part2Sungjoon Choi
 
AlexNet(ImageNet Classification with Deep Convolutional Neural Networks)
AlexNet(ImageNet Classification with Deep Convolutional Neural Networks)AlexNet(ImageNet Classification with Deep Convolutional Neural Networks)
AlexNet(ImageNet Classification with Deep Convolutional Neural Networks)Fellowship at Vodafone FutureLab
 
Introduction to Convolutional Neural Networks
Introduction to Convolutional Neural NetworksIntroduction to Convolutional Neural Networks
Introduction to Convolutional Neural NetworksHannes Hapke
 

What's hot (20)

Image Classification with Deep Learning | DevFest + GDay, George Town, Mala...
Image Classification with Deep Learning  |  DevFest + GDay, George Town, Mala...Image Classification with Deep Learning  |  DevFest + GDay, George Town, Mala...
Image Classification with Deep Learning | DevFest + GDay, George Town, Mala...
 
PyConZA 2019 Keynote - Deep Neural Networks for Video Applications
PyConZA 2019 Keynote - Deep Neural Networks for Video ApplicationsPyConZA 2019 Keynote - Deep Neural Networks for Video Applications
PyConZA 2019 Keynote - Deep Neural Networks for Video Applications
 
Deep Learning in Computer Vision
Deep Learning in Computer VisionDeep Learning in Computer Vision
Deep Learning in Computer Vision
 
ujava.org Deep Learning with Convolutional Neural Network
ujava.org Deep Learning with Convolutional Neural Network ujava.org Deep Learning with Convolutional Neural Network
ujava.org Deep Learning with Convolutional Neural Network
 
Image Classification using deep learning
Image Classification using deep learning Image Classification using deep learning
Image Classification using deep learning
 
Convolutional Neural Network (CNN) - image recognition
Convolutional Neural Network (CNN)  - image recognitionConvolutional Neural Network (CNN)  - image recognition
Convolutional Neural Network (CNN) - image recognition
 
Deep Learning behind Prisma
Deep Learning behind PrismaDeep Learning behind Prisma
Deep Learning behind Prisma
 
AlexNet
AlexNetAlexNet
AlexNet
 
Applied Deep Learning 11/03 Convolutional Neural Networks
Applied Deep Learning 11/03 Convolutional Neural NetworksApplied Deep Learning 11/03 Convolutional Neural Networks
Applied Deep Learning 11/03 Convolutional Neural Networks
 
Deep Learning Tutorial
Deep Learning Tutorial Deep Learning Tutorial
Deep Learning Tutorial
 
Diving into Deep Learning (Silicon Valley Code Camp 2017)
Diving into Deep Learning (Silicon Valley Code Camp 2017)Diving into Deep Learning (Silicon Valley Code Camp 2017)
Diving into Deep Learning (Silicon Valley Code Camp 2017)
 
DRAW: Deep Recurrent Attentive Writer
DRAW: Deep Recurrent Attentive WriterDRAW: Deep Recurrent Attentive Writer
DRAW: Deep Recurrent Attentive Writer
 
Image classification using cnn
Image classification using cnnImage classification using cnn
Image classification using cnn
 
Deep Learning - CNN and RNN
Deep Learning - CNN and RNNDeep Learning - CNN and RNN
Deep Learning - CNN and RNN
 
Modern Convolutional Neural Network techniques for image segmentation
Modern Convolutional Neural Network techniques for image segmentationModern Convolutional Neural Network techniques for image segmentation
Modern Convolutional Neural Network techniques for image segmentation
 
AlexNet(ImageNet Classification with Deep Convolutional Neural Networks)
AlexNet(ImageNet Classification with Deep Convolutional Neural Networks)AlexNet(ImageNet Classification with Deep Convolutional Neural Networks)
AlexNet(ImageNet Classification with Deep Convolutional Neural Networks)
 
RNN and its applications
RNN and its applicationsRNN and its applications
RNN and its applications
 
TensorFlow Tutorial Part2
TensorFlow Tutorial Part2TensorFlow Tutorial Part2
TensorFlow Tutorial Part2
 
AlexNet(ImageNet Classification with Deep Convolutional Neural Networks)
AlexNet(ImageNet Classification with Deep Convolutional Neural Networks)AlexNet(ImageNet Classification with Deep Convolutional Neural Networks)
AlexNet(ImageNet Classification with Deep Convolutional Neural Networks)
 
Introduction to Convolutional Neural Networks
Introduction to Convolutional Neural NetworksIntroduction to Convolutional Neural Networks
Introduction to Convolutional Neural Networks
 

Similar to Convolutional Neural Networks for Image Classification (Cape Town Deep Learning Meet-up 20170620)

Towards better analysis of deep convolutional neural networks
Towards better analysis of deep convolutional neural networksTowards better analysis of deep convolutional neural networks
Towards better analysis of deep convolutional neural networks曾 子芸
 
Teach a neural network to read handwriting
Teach a neural network to read handwritingTeach a neural network to read handwriting
Teach a neural network to read handwritingVipul Kaushal
 
Unsupervised Object Detection
Unsupervised Object DetectionUnsupervised Object Detection
Unsupervised Object DetectionMahan Fathi
 
Deep Neural Networks for Video Applications at the Edge
Deep Neural Networks for Video Applications at the EdgeDeep Neural Networks for Video Applications at the Edge
Deep Neural Networks for Video Applications at the EdgeAlex Conway
 
Convolutional neural network
Convolutional neural network Convolutional neural network
Convolutional neural network Yan Xu
 
Machine Learning - Convolutional Neural Network
Machine Learning - Convolutional Neural NetworkMachine Learning - Convolutional Neural Network
Machine Learning - Convolutional Neural NetworkRichard Kuo
 
Computer vision-nit-silchar-hackathon
Computer vision-nit-silchar-hackathonComputer vision-nit-silchar-hackathon
Computer vision-nit-silchar-hackathonAditya Bhattacharya
 
Convolutional Neural Networks - Xavier Giro - UPC TelecomBCN Barcelona 2020
Convolutional Neural Networks - Xavier Giro - UPC TelecomBCN Barcelona 2020Convolutional Neural Networks - Xavier Giro - UPC TelecomBCN Barcelona 2020
Convolutional Neural Networks - Xavier Giro - UPC TelecomBCN Barcelona 2020Universitat Politècnica de Catalunya
 
A Neural Network that Understands Handwriting
A Neural Network that Understands HandwritingA Neural Network that Understands Handwriting
A Neural Network that Understands HandwritingShivam Sawhney
 
Saptashwa_Mitra_Sitakanta_Mishra_Final_Project_Report
Saptashwa_Mitra_Sitakanta_Mishra_Final_Project_ReportSaptashwa_Mitra_Sitakanta_Mishra_Final_Project_Report
Saptashwa_Mitra_Sitakanta_Mishra_Final_Project_ReportSitakanta Mishra
 
Handwritten Digit Recognition(Convolutional Neural Network) PPT
Handwritten Digit Recognition(Convolutional Neural Network) PPTHandwritten Digit Recognition(Convolutional Neural Network) PPT
Handwritten Digit Recognition(Convolutional Neural Network) PPTRishabhTyagi48
 
CONVOLUTIONAL NEURAL NETWORKS: The workhorse of image and video
CONVOLUTIONAL NEURAL NETWORKS: The workhorse of image and videoCONVOLUTIONAL NEURAL NETWORKS: The workhorse of image and video
CONVOLUTIONAL NEURAL NETWORKS: The workhorse of image and videoCristiano Rafael Steffens
 
FINAL_Team_4.pptx
FINAL_Team_4.pptxFINAL_Team_4.pptx
FINAL_Team_4.pptxnitin571047
 
Artificial Intelligence, Machine Learning and Deep Learning
Artificial Intelligence, Machine Learning and Deep LearningArtificial Intelligence, Machine Learning and Deep Learning
Artificial Intelligence, Machine Learning and Deep LearningSujit Pal
 
Decomposing image generation into layout priction and conditional synthesis
Decomposing image generation into layout priction and conditional synthesisDecomposing image generation into layout priction and conditional synthesis
Decomposing image generation into layout priction and conditional synthesisNaeem Shehzad
 
Mirko Lucchese - Deep Image Processing
Mirko Lucchese - Deep Image ProcessingMirko Lucchese - Deep Image Processing
Mirko Lucchese - Deep Image ProcessingMeetupDataScienceRoma
 
Machine learning project
Machine learning projectMachine learning project
Machine learning projectHarsh Jain
 

Similar to Convolutional Neural Networks for Image Classification (Cape Town Deep Learning Meet-up 20170620) (20)

Towards better analysis of deep convolutional neural networks
Towards better analysis of deep convolutional neural networksTowards better analysis of deep convolutional neural networks
Towards better analysis of deep convolutional neural networks
 
Teach a neural network to read handwriting
Teach a neural network to read handwritingTeach a neural network to read handwriting
Teach a neural network to read handwriting
 
Unsupervised Object Detection
Unsupervised Object DetectionUnsupervised Object Detection
Unsupervised Object Detection
 
Deep Neural Networks for Video Applications at the Edge
Deep Neural Networks for Video Applications at the EdgeDeep Neural Networks for Video Applications at the Edge
Deep Neural Networks for Video Applications at the Edge
 
Convolutional neural network
Convolutional neural network Convolutional neural network
Convolutional neural network
 
Machine Learning - Convolutional Neural Network
Machine Learning - Convolutional Neural NetworkMachine Learning - Convolutional Neural Network
Machine Learning - Convolutional Neural Network
 
Mnist report ppt
Mnist report pptMnist report ppt
Mnist report ppt
 
Computer vision-nit-silchar-hackathon
Computer vision-nit-silchar-hackathonComputer vision-nit-silchar-hackathon
Computer vision-nit-silchar-hackathon
 
Convolutional Neural Networks - Xavier Giro - UPC TelecomBCN Barcelona 2020
Convolutional Neural Networks - Xavier Giro - UPC TelecomBCN Barcelona 2020Convolutional Neural Networks - Xavier Giro - UPC TelecomBCN Barcelona 2020
Convolutional Neural Networks - Xavier Giro - UPC TelecomBCN Barcelona 2020
 
lec6a.ppt
lec6a.pptlec6a.ppt
lec6a.ppt
 
A Neural Network that Understands Handwriting
A Neural Network that Understands HandwritingA Neural Network that Understands Handwriting
A Neural Network that Understands Handwriting
 
Saptashwa_Mitra_Sitakanta_Mishra_Final_Project_Report
Saptashwa_Mitra_Sitakanta_Mishra_Final_Project_ReportSaptashwa_Mitra_Sitakanta_Mishra_Final_Project_Report
Saptashwa_Mitra_Sitakanta_Mishra_Final_Project_Report
 
Handwritten Digit Recognition(Convolutional Neural Network) PPT
Handwritten Digit Recognition(Convolutional Neural Network) PPTHandwritten Digit Recognition(Convolutional Neural Network) PPT
Handwritten Digit Recognition(Convolutional Neural Network) PPT
 
CONVOLUTIONAL NEURAL NETWORKS: The workhorse of image and video
CONVOLUTIONAL NEURAL NETWORKS: The workhorse of image and videoCONVOLUTIONAL NEURAL NETWORKS: The workhorse of image and video
CONVOLUTIONAL NEURAL NETWORKS: The workhorse of image and video
 
Mnist report
Mnist reportMnist report
Mnist report
 
FINAL_Team_4.pptx
FINAL_Team_4.pptxFINAL_Team_4.pptx
FINAL_Team_4.pptx
 
Artificial Intelligence, Machine Learning and Deep Learning
Artificial Intelligence, Machine Learning and Deep LearningArtificial Intelligence, Machine Learning and Deep Learning
Artificial Intelligence, Machine Learning and Deep Learning
 
Decomposing image generation into layout priction and conditional synthesis
Decomposing image generation into layout priction and conditional synthesisDecomposing image generation into layout priction and conditional synthesis
Decomposing image generation into layout priction and conditional synthesis
 
Mirko Lucchese - Deep Image Processing
Mirko Lucchese - Deep Image ProcessingMirko Lucchese - Deep Image Processing
Mirko Lucchese - Deep Image Processing
 
Machine learning project
Machine learning projectMachine learning project
Machine learning project
 

Recently uploaded

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% SecurePooja Nehwal
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxolyaivanovalion
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxolyaivanovalion
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxolyaivanovalion
 
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiVIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiSuhani Kapoor
 
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Delhi Call girls
 
Carero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxCarero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxolyaivanovalion
 
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiLow Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiSuhani Kapoor
 
Smarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxSmarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxolyaivanovalion
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfLars Albertsson
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998YohFuh
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxfirstjob4
 
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一ffjhghh
 
Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxolyaivanovalion
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxolyaivanovalion
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...Suhani Kapoor
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusTimothy Spann
 

Recently uploaded (20)

Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% SecureCall me @ 9892124323  Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
Call me @ 9892124323 Cheap Rate Call Girls in Vashi with Real Photo 100% Secure
 
BigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptxBigBuy dropshipping via API with DroFx.pptx
BigBuy dropshipping via API with DroFx.pptx
 
Mature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptxMature dropshipping via API with DroFx.pptx
Mature dropshipping via API with DroFx.pptx
 
CebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptxCebaBaby dropshipping via API with DroFX.pptx
CebaBaby dropshipping via API with DroFX.pptx
 
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service AmravatiVIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
VIP Call Girls in Amravati Aarohi 8250192130 Independent Escort Service Amravati
 
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
VIP Call Girls Service Charbagh { Lucknow Call Girls Service 9548273370 } Boo...
 
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
Call Girls in Sarai Kale Khan Delhi 💯 Call Us 🔝9205541914 🔝( Delhi) Escorts S...
 
Carero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptxCarero dropshipping via API with DroFx.pptx
Carero dropshipping via API with DroFx.pptx
 
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service BhilaiLow Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
Low Rate Call Girls Bhilai Anika 8250192130 Independent Escort Service Bhilai
 
Smarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptxSmarteg dropshipping via API with DroFx.pptx
Smarteg dropshipping via API with DroFx.pptx
 
Industrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdfIndustrialised data - the key to AI success.pdf
Industrialised data - the key to AI success.pdf
 
RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998RA-11058_IRR-COMPRESS Do 198 series of 1998
RA-11058_IRR-COMPRESS Do 198 series of 1998
 
Introduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptxIntroduction-to-Machine-Learning (1).pptx
Introduction-to-Machine-Learning (1).pptx
 
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一定制英国白金汉大学毕业证(UCB毕业证书)																			成绩单原版一比一
定制英国白金汉大学毕业证(UCB毕业证书) 成绩单原版一比一
 
Ravak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptxRavak dropshipping via API with DroFx.pptx
Ravak dropshipping via API with DroFx.pptx
 
Midocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFxMidocean dropshipping via API with DroFx
Midocean dropshipping via API with DroFx
 
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
VIP High Profile Call Girls Amravati Aarushi 8250192130 Independent Escort Se...
 
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in  KishangarhDelhi 99530 vip 56974 Genuine Escort Service Call Girls in  Kishangarh
Delhi 99530 vip 56974 Genuine Escort Service Call Girls in Kishangarh
 
Generative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and MilvusGenerative AI on Enterprise Cloud with NiFi and Milvus
Generative AI on Enterprise Cloud with NiFi and Milvus
 

Convolutional Neural Networks for Image Classification (Cape Town Deep Learning Meet-up 20170620)

  • 1. Convolutional Neural Networks For Image Classification Alex Conway alex @ numberboost.com Cape Town Deep Learning Meet-up 20 June 2017
  • 4. Big Shout Outs Jeremy Howard & Rachel Thomas http://course.fast.ai Andrej Karpathy http://cs231n.github.io 4
  • 5. 1. What is a neural network? 2. What is an image? 3. What is a convolutional neural network? 4. Using a pre-trained ImageNet-winning CNN 5. Fine-tuning a CNN to solve a new problem 6. Visual similarity “latest AI technology” app 7. Practical tips 8. Image cropping 9. Image captioning 10. CNN + Word2Vec 11. Style transfer 12. Where to from here? 5
  • 6. 1. What is a neural network? 2. What is an image? 3. What is a convolutional neural network? 4. Using a pre-trained ImageNet-winning CNN 5. Fine-tuning a CNN to solve a new problem 6. Visual similarity “latest AI technology” app 7. Practical tips 8. Image cropping 9. Image captioning 10. CNN + Word2Vec 11. Style transfer 12. Where to from here? 6
  • 7. What is a Neural Network? 7
  • 8. What is a Neural Network? 8
  • 9. What is a Neural Network? 9
  • 11. What is a Neural Network? For much more detail, see: 1. Michael Nielson’s Neural Networks & Deep Learning free online book http://neuralnetworksanddeeplearning.com/chap1.html 2. Anrej Karpathy’s CS231n Notes http://neuralnetworksanddeeplearning.com/chap1.html 11
  • 12. What is a Neural Network? Universal Approximation theorem: http://neuralnetworksanddeeplearning.com/chap4.html 12
  • 13. What is an Image? • Pixel = 3 colour channels (R, G, B) • Pixel intensity = number in [0,255] • Image has width w and height h • Therefore image is w x h x 3 numbers 13
  • 14. What is a Convolutional Neural Network (CNN)? CNN = Neural Network + Image - with some tricks - 14
  • 15. What is a Convolutional Neural Network (CNN)? 15
  • 16. Convolutions 16 • 2-d weighted average • Element-wise multiply kernel with pixels • “learn” the kernels • http://setosa.io/ev/image-kernels/ • http://cs231n.github.io/convolutional-networks/
  • 17. Convolutions 17 “imagine taking this 3x3 matrix (“kernel”) and positioning it over a 3x3 area of an image, and let's multiply each overlapping value. Next, let's sum up these products, and let's replace the center pixel with this new value. If we slide this 3x3 matrix over the entire image, we can construct a new image by replacing each pixel in the same manner just described.”
  • 18. Convolutions 18 “...we understand that filters can be used to identify particular visual "elements" of an image, it's easy to see why they're used in deep learning for image recognition. But how do we decide which kinds of filters are the most effective? Specifically, what filters are best at capturing the necessary detail from our image to classify it? • …these filters are just matrices that we are applying to our input to achieve a desired output... therefore, given labelled input, we don't need to manually decide what filters work best at classifying our images, we can simply train a model to do so, using these filters as weights!
  • 19. Convolutions 19 “ ...for example, we can start with 8 randomly generated filters; that is 8 3x3 matrices with random elements. Given labeled inputs, we can then use stochastic gradient descent to determine what the optimal values of these filters are, and therefore we allow the neural network to learn what things are most important to detect in classifying images. “
  • 24. Max Pooling • Reduces dimensionality from one layer to next • By replacing NxN sub-area with max value • Makes network “look” at larger areas of the image at a time e.g. Instead of identifying fur, identify cat • Reduces computational load • Controls for overfitting 24
  • 25. Dropout • Form of regularization (helps prevent overfitting) • Trades ability to fit training data to help generalize to new data • Used during training (not test) • Randomly set weights in hidden layers to 0 with some probability p 25
  • 27. Using a Pre-Trained ImageNet-Winning CNN 27 http://image-net.org/explore
  • 28. Using a Pre-Trained ImageNet-Winning CNN 28
  • 29. Using a Pre-Trained ImageNet-Winning CNN 29 • We’ll be using “VGGNet” • Oxford Visual Geometry Group (VGG) • The runner-up in ILSVRC 2014 • Network contains 16 CONV/FC layers (deep!) • The whole VGGNet is composed of CONV layers that perform 3x3 convolutions with stride 1 and pad 1, and of POOL layers that perform 2x2 max pooling with stride 2 (and no padding) • Its main contribution was in showing that the depth of the network is a critical component for good performance. • Homogeneous architecture that only performs 3x3 convolutions and 2x2 pooling from the beginning to the end. • Easy to fine-tune
  • 30. Using a Pre-Trained ImageNet-Winning CNN 30
  • 31. Using a Pre-Trained ImageNet-Winning CNN 31 CODE TIME! https://github.com/alexcnwy/CTDL_CNN_TALK_20170620
  • 32. Fine-tuning A CNN To Solve A New Problem • Fix weights in convolutional layers (trainable=False) • Re-train final dense layer(s) 32 CODE TIME! https://github.com/alexcnwy/CTDL_CNN_TALK_20170620
  • 33. Visual Similarity “Latest AI Technology” App 33 https://memeburn.com/2017/06/spree-image-search/
  • 34. Visual Similarity “Latest AI Technology” App 34 CODE TIME! • Chop off last 2 layers • Use dense layer with 4096 activations • Compute nearest neighbours in the space of these activations https://github.com/alexcnwy/CTDL_CNN_TALK_20170620
  • 35. Practical Tips • use a GPU – AWS p2 instances not that expensive – much faster • use “adam” / different optimizers SGD variants – http://sebastianruder.com/content/images/2016/09/saddle_point_evaluation_optimizers.gif • look at nvidia-smi • when overfitting - try lower dropout and train longer • when underfitting, try: 1. Add more data 2. Use data augmentation – flipping – slightly changing hues – stretching – shearing – rotation 3. Use more complicated architecture (Resnets, Inception, etc) 35
  • 39. Image Cropping Label the bounding boxes Learn to predict them Just extra input to CNN 39
  • 45. CNN + Word2Vec 45 • Learn the word2vec vectors for each ImangeNet noun
  • 47. Where to From Here? • Clone the repo and train your own model • Do the fast.ai course • Read the cs231n notes • Read http://colah.github.io/posts • Email me questions /ideas :) alex@numberboost.com 47