SlideShare a Scribd company logo
1 of 60
CS294-129: Designing, Visualizing and
Understanding Deep Neural Networks
John Canny
Fall 2016
Lecture 2: Computer Vision and Image Classification
Based on notes from Andrej Karpathy, Fei-Fei Li,
Justin Johnson
Computer Vision – a brief history
David Marr’s approach 1970-80s
• Computation
• Algorithm
• Implementation
primal sketch and
2 ½ D sketch,
Computer Vision – a brief history
Skeletons and Cylinders: Marr and Nishihara 1978:
Tom Binford, generalized
cylinders 1971
Computer Vision - Shape description
ACRONYM (Brooks 1982) matching with generalized
cylinders + search!:
Computer Vision - Shape matching
Turk and Pentland 1991:
A data-driven approach?
Computer Vision - Eigenfaces
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
Computer Vision – Invariant Features
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
Computer Vision – Bag-of-words
Sivic and Zisserman (2003) “Video Google”
SIFT  SA and MS regions code words
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
Computer Vision - Shape matching
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
Computer Vision – Challenge Datasets
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
Computer Vision – Deep Networks
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
Computer Vision – Deep Networks
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
Computer Vision – Deep Networks
Assignment 1 coming out today.
Self-contained, written in Python.
Please submit via bCourses.
Administrivia
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
Image Classification: a core task in Computer Vision
cat
(assume given set of discrete labels)
{dog, cat, truck, plane, ...}
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
The problem:semantic gap
Images are represented as
3D arrays of numbers, with
integers between [0, 255].
E.g.
300 x 100 x 3
(3 for 3 color channels RGB)
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
Challenges: Viewpoint Variation
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
Challenges: Illumination
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
Challenges: Deformation
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
Challenges: Occlusion
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
Challenges: Background clutter
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
Challenges: Intraclass variation
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
An image classifier
Unlike e.g. sorting a list of numbers,
no obvious way to hard-code the algorithm for
recognizing a cat, or other classes.
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
Classifying using constraints? ?
???
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
1. Collect a dataset of images and labels
2. Use Machine Learning to train an image classifier
3. Evaluate the classifier on a withheld set of test images
Example training set
Data-driven approach:
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
First classifier: Nearest Neighbor Classifier
Remember all training
images and their labels
Predict the label of the
most similar training image
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
10 labels
50,000 training images, each image is tiny: 32x32
10,000 test images.
Example dataset: CIFAR-10
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
For every test image (first column),
examples of nearest neighbors in rows
10 labels
50,000 training images
10,000 test images.
Example dataset: CIFAR-10
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
How do we compare the images?
What is the distance metric?
L1 distance:
add
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
Nearest Neighbor classifier
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
Nearest Neighbor classifier
remember the training data
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
Nearest Neighbor classifier
for every test image:
- find nearest train image
with L1 distance
- predict the label of
nearest training image
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
Nearest Neighbor classifier
Q: how does the
classification speed
depend on the size of
the training data?
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
Nearest Neighbor classifier
Q: how does the
classification speed
depend on the size of
the training data?
linearly :(
This is backwards:
- test time performance
is usually much more
important in practice.
- CNNs flip this:
expensive training,
cheap test evaluation
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
Aside: Approximate Nearest Neighbor
find approximate nearest neighbors quickly
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
The choice of distance is a hyperparameter
common choices:
L1 (Manhattan) distance L2 (Euclidean) distance
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
k-Nearest Neighbor
find the k nearest images, have them vote on the label
the data NN classifier 5-NN classifier
http://en.wikipedia.org/wiki/K-nearest_neighbors_algorithm
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
For every test image (first column),
examples of nearest neighbors in rows
10 labels
50,000 training images
10,000 test images.
Example dataset: CIFAR-10
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
Q: what is the accuracy of the nearest
neighbor classifier on the training data,
when using the Euclidean distance?
the data NN classifier 5-NN classifier
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
Q2: what is the accuracy of the k-nearest
neighbor classifier on the training data?
the data NN classifier 5-NN classifier
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
What is the best distance to use?
What is the best value of k to use?
i.e. how do we set the hyperparameters?
Hyperparameter tuning:
Recall from statistics (or ML), given a true function y=f(x)
(mapping an input x to a label y), a machine learning
algorithm is a statistical estimator gD(x). Here D is a data
sample.
Estimators have:
• Bias: gD(x) is systematically different from f(x), i.e.
ED(gD(x))  f(x)
• Variance: VARD(gD(x)). Even if no bias, gD(x) may be far
from f(x) at most points x.
Bias and Variance
Increasing k in the kNN algorithm should have what effect
on:
Bias: ?
Variance: ?
Bias and Variance
Increasing k in the kNN algorithm should have what effect
on:
Bias: Should increase. The large k is, the further (on
average) are the points being aggregated from x. i.e. the
value depends on f(x’) for x’ further from x.
Variance: ?
Bias and Variance
Bias
f(x) 5 neighbors
Aggregate is systematically
Biased down
Increasing k in the kNN algorithm should have what effect
on:
Bias: Should increase. The large k is, the further (on
average) are the points being aggregated from x. i.e. the
value depends on f(x’) for x’ further from x.
Variance: Should decrease. The average or majority vote
of a set of equal-variance values has lower variance than
each value.
Bias and Variance
Variance
f(x)
5 neighbors
Variance of mean of k samples
scaled by 1/k
Compared to simpler (fewer parameters), complex models
have what kind of Bias and Variance?:
Bias: ?
Variance:?
Bias and Variance Rule of Thumb
Compared to simpler (fewer parameters), complex models
have what kind of Bias and Variance?:
Bias: ? Lower, because complex models can better model
local variation in f(x).
Variance:?
Bias and Variance Rule of Thumb
Compared to simpler (fewer parameters), complex models
have what kind of Bias and Variance?:
Bias: ? Lower, because complex models can better model
local variation in f(x).
Variance:? Higher, because the parameters are generally
more sensitive to few data values.
Bias and Variance Rule of Thumb
Compared to simpler (fewer parameters), complex models
have what kind of Bias and Variance?:
Bias: ? Lower, because complex models can better model
local variation in f(x).
Variance:? Higher, because the parameters are generally
more sensitive to few data values.
Complex models are prone to overfitting. They
require/benefit from large training datasets in order to
reduce variance. This includes most Deep Networks.
Bias and Variance Rule of Thumb
This rule of thumb is important to keep in mind, but it is only
a rule of thumb, not a theorem. It applies to typical ML
algorithms and deep networks, but not all.
A mathematical theorem is like a hammer. A rule of thumb
is no match for it…
Bias and Variance Rule of Thumb
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
What is the best distance to use?
What is the best value of k to use?
i.e. how do we set the hyperparameters?
Very problem-dependent.
Must try them all out and see what works best.
Hyperparameter tuning:
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
Try out what hyperparameters work best on test set.
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
Trying out what hyperparameters work best on test set:
Very bad idea. The test set is a proxy for the generalization performance!
Use only VERY SPARINGLY, at the end.
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
Validation data
use to tune hyperparameters
Validation Set:
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
Cross-validation
cycle through the choice of which fold
is the validation fold, average results.
Validation Set:
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
Example of
5-fold cross-validation
for the value of k.
Each point: single
outcome.
The line goes
through the mean, bars
indicated standard
deviation
(Seems that k ~= 7 works best
for this data)
Hyperparameter tuning:
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
k-Nearest Neighbor on images never used.
• terrible performance at test time
• distance metrics on level of whole images can be
very unintuitive
(all 3 images have same L2 distance to the one on the left)
Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson
Summary
• Image Classification: given a Training Set of labeled
images, predict labels on Test Set. Common to report the
Accuracy of predictions (fraction of correct predictions)
• We introduced the k-Nearest Neighbor Classifier, which
predicts labels based on nearest images in the training set
• We saw that the choice of distance and the value of k are
hyperparameters that are tuned using a validation set, or
through cross-validation if the size of the data is small.
• Once the best set of hyperparameters is chosen, the
classifier is evaluated once on the test set, and reported as
the performance of kNN on that data.

More Related Content

Similar to lec02.pptx

Representative Previous Work
Representative Previous WorkRepresentative Previous Work
Representative Previous Workbutest
 
The Machinery behind Deep Learning
The Machinery behind Deep LearningThe Machinery behind Deep Learning
The Machinery behind Deep LearningStefan Kühn
 
Visual geometry with deep learning
Visual geometry with deep learningVisual geometry with deep learning
Visual geometry with deep learningNAVER Engineering
 
K- Nearest Neighbor Approach
K- Nearest Neighbor ApproachK- Nearest Neighbor Approach
K- Nearest Neighbor ApproachKumud Arora
 
Shai Avidan's Support vector tracking and ensemble tracking
Shai Avidan's Support vector tracking and ensemble trackingShai Avidan's Support vector tracking and ensemble tracking
Shai Avidan's Support vector tracking and ensemble trackingwolf
 
Week06 bme429-cbir
Week06 bme429-cbirWeek06 bme429-cbir
Week06 bme429-cbirIkram Moalla
 
23 Machine Learning Feature Generation
23 Machine Learning Feature Generation23 Machine Learning Feature Generation
23 Machine Learning Feature GenerationAndres Mendez-Vazquez
 
T. Lucas Makinen x Imperial SBI Workshop
T. Lucas Makinen x Imperial SBI WorkshopT. Lucas Makinen x Imperial SBI Workshop
T. Lucas Makinen x Imperial SBI WorkshopLucasMakinen1
 
LCBM: Statistics-Based Parallel Collaborative Filtering
LCBM: Statistics-Based Parallel Collaborative FilteringLCBM: Statistics-Based Parallel Collaborative Filtering
LCBM: Statistics-Based Parallel Collaborative FilteringFabio Petroni, PhD
 
Recommender Systems with Implicit Feedback Challenges, Techniques, and Applic...
Recommender Systems with Implicit Feedback Challenges, Techniques, and Applic...Recommender Systems with Implicit Feedback Challenges, Techniques, and Applic...
Recommender Systems with Implicit Feedback Challenges, Techniques, and Applic...NAVER Engineering
 
lecture01_lecture01_lecture0001_ceva.pdf
lecture01_lecture01_lecture0001_ceva.pdflecture01_lecture01_lecture0001_ceva.pdf
lecture01_lecture01_lecture0001_ceva.pdfAnaNeacsu5
 
Deep Reinforcement Learning: MDP & DQN - Xavier Giro-i-Nieto - UPC Barcelona ...
Deep Reinforcement Learning: MDP & DQN - Xavier Giro-i-Nieto - UPC Barcelona ...Deep Reinforcement Learning: MDP & DQN - Xavier Giro-i-Nieto - UPC Barcelona ...
Deep Reinforcement Learning: MDP & DQN - Xavier Giro-i-Nieto - UPC Barcelona ...Universitat Politècnica de Catalunya
 
Practical Digital Image Processing 5
Practical Digital Image Processing 5Practical Digital Image Processing 5
Practical Digital Image Processing 5Aly Abdelkareem
 

Similar to lec02.pptx (20)

Representative Previous Work
Representative Previous WorkRepresentative Previous Work
Representative Previous Work
 
K-Nearest Neighbor(KNN)
K-Nearest Neighbor(KNN)K-Nearest Neighbor(KNN)
K-Nearest Neighbor(KNN)
 
Fa18_P2.pptx
Fa18_P2.pptxFa18_P2.pptx
Fa18_P2.pptx
 
The Machinery behind Deep Learning
The Machinery behind Deep LearningThe Machinery behind Deep Learning
The Machinery behind Deep Learning
 
Visual geometry with deep learning
Visual geometry with deep learningVisual geometry with deep learning
Visual geometry with deep learning
 
pml.pdf
pml.pdfpml.pdf
pml.pdf
 
K- Nearest Neighbor Approach
K- Nearest Neighbor ApproachK- Nearest Neighbor Approach
K- Nearest Neighbor Approach
 
Shai Avidan's Support vector tracking and ensemble tracking
Shai Avidan's Support vector tracking and ensemble trackingShai Avidan's Support vector tracking and ensemble tracking
Shai Avidan's Support vector tracking and ensemble tracking
 
Knn
KnnKnn
Knn
 
Week06 bme429-cbir
Week06 bme429-cbirWeek06 bme429-cbir
Week06 bme429-cbir
 
ilp-nlp-slides.pdf
ilp-nlp-slides.pdfilp-nlp-slides.pdf
ilp-nlp-slides.pdf
 
23 Machine Learning Feature Generation
23 Machine Learning Feature Generation23 Machine Learning Feature Generation
23 Machine Learning Feature Generation
 
T. Lucas Makinen x Imperial SBI Workshop
T. Lucas Makinen x Imperial SBI WorkshopT. Lucas Makinen x Imperial SBI Workshop
T. Lucas Makinen x Imperial SBI Workshop
 
LCBM: Statistics-Based Parallel Collaborative Filtering
LCBM: Statistics-Based Parallel Collaborative FilteringLCBM: Statistics-Based Parallel Collaborative Filtering
LCBM: Statistics-Based Parallel Collaborative Filtering
 
Recommender Systems with Implicit Feedback Challenges, Techniques, and Applic...
Recommender Systems with Implicit Feedback Challenges, Techniques, and Applic...Recommender Systems with Implicit Feedback Challenges, Techniques, and Applic...
Recommender Systems with Implicit Feedback Challenges, Techniques, and Applic...
 
lecture01_lecture01_lecture0001_ceva.pdf
lecture01_lecture01_lecture0001_ceva.pdflecture01_lecture01_lecture0001_ceva.pdf
lecture01_lecture01_lecture0001_ceva.pdf
 
Deep Reinforcement Learning: MDP & DQN - Xavier Giro-i-Nieto - UPC Barcelona ...
Deep Reinforcement Learning: MDP & DQN - Xavier Giro-i-Nieto - UPC Barcelona ...Deep Reinforcement Learning: MDP & DQN - Xavier Giro-i-Nieto - UPC Barcelona ...
Deep Reinforcement Learning: MDP & DQN - Xavier Giro-i-Nieto - UPC Barcelona ...
 
Object Detection (D2L5 Insight@DCU Machine Learning Workshop 2017)
Object Detection (D2L5 Insight@DCU Machine Learning Workshop 2017)Object Detection (D2L5 Insight@DCU Machine Learning Workshop 2017)
Object Detection (D2L5 Insight@DCU Machine Learning Workshop 2017)
 
D3L4-objects.pdf
D3L4-objects.pdfD3L4-objects.pdf
D3L4-objects.pdf
 
Practical Digital Image Processing 5
Practical Digital Image Processing 5Practical Digital Image Processing 5
Practical Digital Image Processing 5
 

Recently uploaded

High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.eptoze12
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 

Recently uploaded (20)

High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.Oxy acetylene welding presentation note.
Oxy acetylene welding presentation note.
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 

lec02.pptx

  • 1. CS294-129: Designing, Visualizing and Understanding Deep Neural Networks John Canny Fall 2016 Lecture 2: Computer Vision and Image Classification Based on notes from Andrej Karpathy, Fei-Fei Li, Justin Johnson
  • 2. Computer Vision – a brief history
  • 3. David Marr’s approach 1970-80s • Computation • Algorithm • Implementation primal sketch and 2 ½ D sketch, Computer Vision – a brief history
  • 4. Skeletons and Cylinders: Marr and Nishihara 1978: Tom Binford, generalized cylinders 1971 Computer Vision - Shape description
  • 5. ACRONYM (Brooks 1982) matching with generalized cylinders + search!: Computer Vision - Shape matching
  • 6. Turk and Pentland 1991: A data-driven approach? Computer Vision - Eigenfaces
  • 7. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson Computer Vision – Invariant Features
  • 8. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson Computer Vision – Bag-of-words Sivic and Zisserman (2003) “Video Google” SIFT  SA and MS regions code words
  • 9. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson Computer Vision - Shape matching
  • 10. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson Computer Vision – Challenge Datasets
  • 11. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson Computer Vision – Deep Networks
  • 12. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson Computer Vision – Deep Networks
  • 13. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson Computer Vision – Deep Networks
  • 14. Assignment 1 coming out today. Self-contained, written in Python. Please submit via bCourses. Administrivia
  • 15. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson Image Classification: a core task in Computer Vision cat (assume given set of discrete labels) {dog, cat, truck, plane, ...}
  • 16. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson The problem:semantic gap Images are represented as 3D arrays of numbers, with integers between [0, 255]. E.g. 300 x 100 x 3 (3 for 3 color channels RGB)
  • 17. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson Challenges: Viewpoint Variation
  • 18. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson Challenges: Illumination
  • 19. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson Challenges: Deformation
  • 20. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson Challenges: Occlusion
  • 21. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson Challenges: Background clutter
  • 22. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson Challenges: Intraclass variation
  • 23. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson An image classifier Unlike e.g. sorting a list of numbers, no obvious way to hard-code the algorithm for recognizing a cat, or other classes.
  • 24. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson Classifying using constraints? ? ???
  • 25. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson 1. Collect a dataset of images and labels 2. Use Machine Learning to train an image classifier 3. Evaluate the classifier on a withheld set of test images Example training set Data-driven approach:
  • 26. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson First classifier: Nearest Neighbor Classifier Remember all training images and their labels Predict the label of the most similar training image
  • 27. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson 10 labels 50,000 training images, each image is tiny: 32x32 10,000 test images. Example dataset: CIFAR-10
  • 28. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson For every test image (first column), examples of nearest neighbors in rows 10 labels 50,000 training images 10,000 test images. Example dataset: CIFAR-10
  • 29. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson How do we compare the images? What is the distance metric? L1 distance: add
  • 30. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson Nearest Neighbor classifier
  • 31. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson Nearest Neighbor classifier remember the training data
  • 32. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson Nearest Neighbor classifier for every test image: - find nearest train image with L1 distance - predict the label of nearest training image
  • 33. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson Nearest Neighbor classifier Q: how does the classification speed depend on the size of the training data?
  • 34. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson Nearest Neighbor classifier Q: how does the classification speed depend on the size of the training data? linearly :( This is backwards: - test time performance is usually much more important in practice. - CNNs flip this: expensive training, cheap test evaluation
  • 35. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson Aside: Approximate Nearest Neighbor find approximate nearest neighbors quickly
  • 36. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson The choice of distance is a hyperparameter common choices: L1 (Manhattan) distance L2 (Euclidean) distance
  • 37. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson k-Nearest Neighbor find the k nearest images, have them vote on the label the data NN classifier 5-NN classifier http://en.wikipedia.org/wiki/K-nearest_neighbors_algorithm
  • 38. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson For every test image (first column), examples of nearest neighbors in rows 10 labels 50,000 training images 10,000 test images. Example dataset: CIFAR-10
  • 39. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson Q: what is the accuracy of the nearest neighbor classifier on the training data, when using the Euclidean distance? the data NN classifier 5-NN classifier
  • 40. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson Q2: what is the accuracy of the k-nearest neighbor classifier on the training data? the data NN classifier 5-NN classifier
  • 41. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson What is the best distance to use? What is the best value of k to use? i.e. how do we set the hyperparameters? Hyperparameter tuning:
  • 42. Recall from statistics (or ML), given a true function y=f(x) (mapping an input x to a label y), a machine learning algorithm is a statistical estimator gD(x). Here D is a data sample. Estimators have: • Bias: gD(x) is systematically different from f(x), i.e. ED(gD(x))  f(x) • Variance: VARD(gD(x)). Even if no bias, gD(x) may be far from f(x) at most points x. Bias and Variance
  • 43. Increasing k in the kNN algorithm should have what effect on: Bias: ? Variance: ? Bias and Variance
  • 44. Increasing k in the kNN algorithm should have what effect on: Bias: Should increase. The large k is, the further (on average) are the points being aggregated from x. i.e. the value depends on f(x’) for x’ further from x. Variance: ? Bias and Variance
  • 45. Bias f(x) 5 neighbors Aggregate is systematically Biased down
  • 46. Increasing k in the kNN algorithm should have what effect on: Bias: Should increase. The large k is, the further (on average) are the points being aggregated from x. i.e. the value depends on f(x’) for x’ further from x. Variance: Should decrease. The average or majority vote of a set of equal-variance values has lower variance than each value. Bias and Variance
  • 47. Variance f(x) 5 neighbors Variance of mean of k samples scaled by 1/k
  • 48. Compared to simpler (fewer parameters), complex models have what kind of Bias and Variance?: Bias: ? Variance:? Bias and Variance Rule of Thumb
  • 49. Compared to simpler (fewer parameters), complex models have what kind of Bias and Variance?: Bias: ? Lower, because complex models can better model local variation in f(x). Variance:? Bias and Variance Rule of Thumb
  • 50. Compared to simpler (fewer parameters), complex models have what kind of Bias and Variance?: Bias: ? Lower, because complex models can better model local variation in f(x). Variance:? Higher, because the parameters are generally more sensitive to few data values. Bias and Variance Rule of Thumb
  • 51. Compared to simpler (fewer parameters), complex models have what kind of Bias and Variance?: Bias: ? Lower, because complex models can better model local variation in f(x). Variance:? Higher, because the parameters are generally more sensitive to few data values. Complex models are prone to overfitting. They require/benefit from large training datasets in order to reduce variance. This includes most Deep Networks. Bias and Variance Rule of Thumb
  • 52. This rule of thumb is important to keep in mind, but it is only a rule of thumb, not a theorem. It applies to typical ML algorithms and deep networks, but not all. A mathematical theorem is like a hammer. A rule of thumb is no match for it… Bias and Variance Rule of Thumb
  • 53. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson What is the best distance to use? What is the best value of k to use? i.e. how do we set the hyperparameters? Very problem-dependent. Must try them all out and see what works best. Hyperparameter tuning:
  • 54. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson Try out what hyperparameters work best on test set.
  • 55. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson Trying out what hyperparameters work best on test set: Very bad idea. The test set is a proxy for the generalization performance! Use only VERY SPARINGLY, at the end.
  • 56. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson Validation data use to tune hyperparameters Validation Set:
  • 57. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson Cross-validation cycle through the choice of which fold is the validation fold, average results. Validation Set:
  • 58. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson Example of 5-fold cross-validation for the value of k. Each point: single outcome. The line goes through the mean, bars indicated standard deviation (Seems that k ~= 7 works best for this data) Hyperparameter tuning:
  • 59. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson k-Nearest Neighbor on images never used. • terrible performance at test time • distance metrics on level of whole images can be very unintuitive (all 3 images have same L2 distance to the one on the left)
  • 60. Slides based on cs231n by Fei-Fei Li & Andrej Karpathy & Justin Johnson Summary • Image Classification: given a Training Set of labeled images, predict labels on Test Set. Common to report the Accuracy of predictions (fraction of correct predictions) • We introduced the k-Nearest Neighbor Classifier, which predicts labels based on nearest images in the training set • We saw that the choice of distance and the value of k are hyperparameters that are tuned using a validation set, or through cross-validation if the size of the data is small. • Once the best set of hyperparameters is chosen, the classifier is evaluated once on the test set, and reported as the performance of kNN on that data.

Editor's Notes

  1. Where to put block multi-vector algorithms? Percentage of Future Work Diagram
  2. Computer vision, a good challenge for a summer project
  3. David Marr, visual models grounded in psycho-physics
  4. World-centered representations
  5. Arguably realizes the Marr pipeline
  6. Works when you have lots of views of each face, leverages fast computation (matrix algebra)
  7. Arguably realizes the Marr pipeline