PPT

advertisement
Image classification
• Given the bag-of-features representations of
images from different classes, how do we
learn a model for distinguishing them?
Classifiers
• Learn a decision rule assigning bag-offeatures representations of images to
different classes
Decision
boundary
Zebra
Non-zebra
Classification
• Assign input vector to one of two or more
classes
• Any decision rule divides input space into
decision regions separated by decision
boundaries
Nearest Neighbor Classifier
• Assign label of nearest training data point to each test data
point
from Duda et al.
Voronoi partitioning of feature space
for two-category 2D and 3D data
Source: D. Lowe
K-Nearest Neighbors
• For a new point, find the k closest points from training data
• Labels of the k points “vote” to classify
• Works well provided there is lots of data and the distance
function is good
k=5
Source: D. Lowe
Functions for comparing histograms
N
• L1 distance:
• χ2 distance:
D(h1 , h2 )   | h1 (i )  h2 (i ) |
i 1
N
D (h1 , h2 )  
i 1
h1 (i)  h2 (i) 2
h1 (i )  h2 (i )
• Quadratic distance (cross-bin distance):
D(h1 , h2 )   Aij (h1 (i)  h2 ( j )) 2
i, j
• Histogram intersection (similarity function):
N
I (h1 , h2 )   min( h1 (i ), h2 (i ))
i 1
Linear classifiers
• Find linear function (hyperplane) to separate
positive and negative examples
xi positive :
xi  w  b  0
xi negative :
xi  w  b  0
Which hyperplane
is best?
Support vector machines
• Find hyperplane that maximizes the margin
between the positive and negative examples
C. Burges, A Tutorial on Support Vector Machines for Pattern Recognition, Data Mining
and Knowledge Discovery, 1998
Support vector machines
• Find hyperplane that maximizes the margin
between the positive and negative examples
xi positive ( yi  1) :
xi  w  b  1
xi negative ( yi  1) :
xi  w  b  1
For support vectors,
xi  w  b  1
Distance between point
and hyperplane:
| xi  w  b |
|| w ||
Therefore, the margin is 2 / ||w||
Support vectors
Margin
C. Burges, A Tutorial on Support Vector Machines for Pattern Recognition, Data Mining
and Knowledge Discovery, 1998
Finding the maximum margin hyperplane
1. Maximize margin 2/||w||
2. Correctly classify all training data:
xi positive ( yi  1) :
xi  w  b  1
xi negative ( yi  1) :
xi  w  b  1
Quadratic optimization problem:
1 T
Minimize
w w
2
Subject to yi(w·xi+b) ≥ 1
C. Burges, A Tutorial on Support Vector Machines for Pattern Recognition, Data Mining
and Knowledge Discovery, 1998
Finding the maximum margin hyperplane
• Solution: w  i  i yi xi
learned
weight
Support
vector
C. Burges, A Tutorial on Support Vector Machines for Pattern Recognition, Data Mining
and Knowledge Discovery, 1998
Finding the maximum margin hyperplane
• Solution: w  i  i yi xi
b = yi – w·xi for any support vector
• Classification function (decision boundary):
w  x  b  i  i yi xi  x  b
• Notice that it relies on an inner product between
the test point x and the support vectors xi
• Solving the optimization problem also involves
computing the inner products xi · xj between all
pairs of training points
C. Burges, A Tutorial on Support Vector Machines for Pattern Recognition, Data Mining
and Knowledge Discovery, 1998
Nonlinear SVMs
• Datasets that are linearly separable work out great:
x
0
• But what if the dataset is just too hard?
x
0
• We can map it to a higher-dimensional space:
x2
0
x
Slide credit: Andrew Moore
Nonlinear SVMs
• General idea: the original input space can
always be mapped to some higher-dimensional
feature space where the training set is
separable:
Φ: x → φ(x)
Slide credit: Andrew Moore
Nonlinear SVMs
• The kernel trick: instead of explicitly computing
the lifting transformation φ(x), define a kernel
function K such that
K(xi ,xj) = φ(xi ) · φ(xj)
(to be valid, the kernel function must satisfy
Mercer’s condition)
• This gives a nonlinear decision boundary in the
original feature space:
 y  ( x )  ( x)  b   y K ( x , x)  b
i
i
i
i
i
i
i
i
C. Burges, A Tutorial on Support Vector Machines for Pattern Recognition, Data Mining
and Knowledge Discovery, 1998
Nonlinear kernel: Example
2
• Consider the mapping  ( x)  ( x, x )
x2
 ( x)   ( y)  ( x, x 2 )  ( y, y 2 )  xy  x 2 y 2
K ( x, y)  xy  x 2 y 2
Kernels for bags of features
• Histogram intersection kernel:
N
I (h1 , h2 )   min( h1 (i ), h2 (i ))
i 1
• Generalized Gaussian kernel:
 1
2
K (h1 , h2 )  exp   D(h1 , h2 ) 
 A

• D can be L1 distance, Euclidean distance,
χ2 distance, etc.
J. Zhang, M. Marszalek, S. Lazebnik, and C. Schmid, Local Features and Kernels for
Classifcation of Texture and Object Categories: A Comprehensive Study, IJCV 2007
Summary: SVMs for image classification
1. Pick an image representation (in our case, bag
of features)
2. Pick a kernel function for that representation
3. Compute the matrix of kernel values between
every pair of training examples
4. Feed the kernel matrix into your favorite SVM
solver to obtain support vectors and weights
5. At test time: compute kernel values for your test
example and each support vector, and combine
them with the learned weights to get the value of
the decision function
What about multi-class SVMs?
• Unfortunately, there is no “definitive” multiclass SVM formulation
• In practice, we have to obtain a multi-class
SVM by combining multiple two-class SVMs
• One vs. others
• Traning: learn an SVM for each class vs. the others
• Testing: apply each SVM to test example and assign to it the
class of the SVM that returns the highest decision value
• One vs. one
• Training: learn an SVM for each pair of classes
• Testing: each learned SVM “votes” for a class to assign to
the test example
SVMs: Pros and cons
• Pros
• Many publicly available SVM packages:
http://www.kernel-machines.org/software
• Kernel-based framework is very powerful, flexible
• SVMs work very well in practice, even with very small
training sample sizes
• Cons
• No “direct” multi-class SVM, must combine two-class SVMs
• Computation, memory
– During training time, must compute matrix of kernel values for
every pair of examples
– Learning can take a very long time for large-scale problems
Summary: Classifiers
• Nearest-neighbor and k-nearest-neighbor
classifiers
• L1 distance, χ2 distance, quadratic distance, histogram
intersection
• Support vector machines
•
•
•
•
Linear classifiers
Margin maximization
The kernel trick
Kernel functions: histogram intersection, generalized
Gaussian, pyramid match
• Multi-class
• Of course, there are many other classifiers
out there
• Neural networks, boosting, decision trees, …
Download