Generalization + Globa Image Features Various slides from previous - - PowerPoint PPT Presentation

generalization globa image features
SMART_READER_LITE
LIVE PREVIEW

Generalization + Globa Image Features Various slides from previous - - PowerPoint PPT Presentation

CS4501: Introduction to Computer Vision Generalization + Globa Image Features Various slides from previous courses by: D.A. Forsyth (Berkeley / UIUC), I. Kokkinos (Ecole Centrale / UCL). S. Lazebnik (UNC / UIUC), S. Seitz (MSR / Facebook), J.


slide-1
SLIDE 1

CS4501: Introduction to Computer Vision

Generalization + Globa Image Features

Various slides from previous courses by: D.A. Forsyth (Berkeley / UIUC), I. Kokkinos (Ecole Centrale / UCL). S. Lazebnik (UNC / UIUC), S. Seitz (MSR / Facebook), J. Hays (Brown / Georgia Tech), A. Berg (Stony Brook / UNC), D. Samaras (Stony Brook) . J. M. Frahm (UNC), V. Ordonez (UVA), Steve Seitz (UW).

slide-2
SLIDE 2
  • Softmax Classifier (Linear Classifiers)
  • Stochastic Gradient Descent

Last Class

slide-3
SLIDE 3
  • Generalization / Overfitting / Regularization
  • Global Image Features

Today’s Class

slide-4
SLIDE 4

4

Supervised Learning - Classification

cat cat dog bear

Training Data

!" = [ ] !' = [ ] !( = [ ] !) = [ ] *) = [ ] *( = [ ] *' = [ ] *" = [ ] . . .

slide-5
SLIDE 5

5

Supervised Learning - Classification

Training Data

1 1 2 3

!" = !$ = !% = !& = '& = ['&& '&% '&$ '&*] '% = ['%& '%% '%$ '%*] '$ = ['$& '$% '$$ '$*] '" = ['"& '"% '"$ '"*] . . .

!,

  • = .(',; 1)

We need to find a function that maps x and y for any of them. How do we ”learn” the parameters

  • f this function?

We choose ones that makes the following quantity small:

3 4567(!,

  • , !,)

" ,9&

inputs targets / labels / ground truth

1 2 2 1

! :" = ! :$ = ! :% = ! :& =

predictions

slide-6
SLIDE 6

6

Supervised Learning –Softmax Classifier

Training Data

1 1 2 3

!" = !$ = !% = !& = '& = ['&& '&% '&$ '&*] '% = ['%& '%% '%$ '%*] '$ = ['$& '$% '$$ '$*] '" = ['"& '"% '"$ '"*] . . .

inputs targets / labels / ground truth

slide-7
SLIDE 7

7

Training Data

[1 0 0] [1 0 0] [0 1 0] [0 0 1]

!" = !$ = !% = !& = '& = ['&& '&% '&$ '&*] '% = ['%& '%% '%$ '%*] '$ = ['$& '$% '$$ '$*] '" = ['"& '"% '"$ '"*] . . .

inputs targets / labels / ground truth

[0.85 0.10 0.05] [0.40 0.45 0.05] [0.20 0.70 0.10] [0.40 0.25 0.35]

! ," = ! ,$ = ! ,% = ! ,& =

predictions

Supervised Learning –Softmax Classifier

slide-8
SLIDE 8

8

[1 0 0]

!" = $" = [$"& $"( $") $"*] ! ," = [-

. - / - 0]

  • 1. = 2.&$"& + 2.($"( + 2.)$") + 2.*$"* + 4.

1/ = 2/&$"& + 2/($"( + 2/)$") + 2/*$"* + 4/ 10 = 20&$"& + 20($"( + 20)$") + 20*$"* + 40

  • . = 567/(567+56: + 56;)
  • / = 56:/(567+56: + 56;)
  • 0 = 56;/(567+56: + 56;)

Supervised Learning –Softmax Classifier

slide-9
SLIDE 9

9

How do we find a good w and b?

[1 0 0]

!" = $" = [$"& $"( $") $"*] ! ," = [-

.(0, 2) - 4(0, 2) - 5(0, 2)]

We need to find w, and b that minimize the following function L: 6 0, 2 = 7 7 −!",9log (! ,",9)

) 9=& > "=&

Why? = 7 −log (! ,",?@5A?)

> "=&

= 7 −log -

",?@5A?(0, 2) > "=&

slide-10
SLIDE 10

10

Gradient Descent (GD)

!(#, %) = ( −log .

/,01230(#, %) 4 /56

7 = 0.01 for e = 0, num_epochs do end Initialize w and b randomly ;!(#, %)/;# ;!(#, %)/;% Compute: and Update w: Update b: # = # − 7 ;!(#, %)/;# % = % − 7 ;!(#, %)/;% Print: !(#, %) // Useful to see if this is becoming smaller or not. Problem: expensive!

slide-11
SLIDE 11

11

Solution: (mini-batch) Stochastic Gradient Descent (SGD)

!(#, %) = ( −log .

/,01230(#, %) /∈5

6 = 0.01 for e = 0, num_epochs do end Initialize w and b randomly :!(#, %)/:# :!(#, %)/:% Compute: and Update w: Update b: # = # − 6 :!(#, %)/:# % = % − 6 :!(#, %)/:% Print: !(#, %) // Useful to see if this is becoming smaller or not. end for b = 0, num_batches do B is a small set of training examples.

slide-12
SLIDE 12

Source: Andrew Ng

slide-13
SLIDE 13

13

Three more things

  • How to compute the gradient
  • Regularization
  • Momentum updates
slide-14
SLIDE 14

SGD Gradient for the Softmax Function

slide-15
SLIDE 15

SGD Gradient for the Softmax Function

slide-16
SLIDE 16

SGD Gradient for the Softmax Function

slide-17
SLIDE 17

17

Supervised Learning –Softmax Classifier

!" = [!"% !"' !"( !")]

Extract features

+, = -,%!"% + -,'!"' + -,(!"( + -,)!") + /, +0 = -0%!"% + -0'!"' + -0(!"( + -0)!") + /0 +1 = -1%!"% + -1'!"' + -1(!"( + -1)!") + /1 2

, = 345/(345+348 + 349)

2

0 = 348/(345+348 + 349)

2

1 = 349/(345+348 + 349)

Run features through classifier

; <" = [2

, 2 0 2 1]

Get predictions

slide-18
SLIDE 18

Prediction

Supervised Machine Learning Steps

Training Labels Training Images Training

Training

Image Features Image Features

Testing

Test Image Learned model Learned model

Slide credit: D. Hoiem

slide-19
SLIDE 19

Generalization

  • Generalization refers to the ability to correctly classify never before

seen examples

  • Can be controlled by turning “knobs” that affect the complexity of

the model

Training set (labels known) Test set (labels unknown)

slide-20
SLIDE 20

Overfitting

!"## $ is high !"## $ is low !"## $ is zero! Overfitting Underfitting High Bias High Variance

% is linear % is cubic % is a polynomial of degree 9

slide-21
SLIDE 21

Pytorch: Project Assignment 4

  • http://vicenteordonez.com/vision/
slide-22
SLIDE 22

Prediction

Supervised Machine Learning Steps

Training Labels Training Images Training

Training

Image Features Image Features

Testing

Test Image Learned model Learned model

Slide credit: D. Hoiem

slide-23
SLIDE 23

Image Features

  • In your Project 4: Nearest Neighbors + Softmax Classifier features are:

Image: 3x32x32 Feature: 3072-dim vector

slide-24
SLIDE 24

Image Features: Color

Photo by: marielito

slide by Tamara L. Berg

slide-25
SLIDE 25

Image Features: Color

slide-26
SLIDE 26

Image Features: Color

However, these are all images of people but the colors in each image are very different.

slide-27
SLIDE 27

Image Features: HoG

Scikit-image implementation

Paper by Navneet Dalal & Bill Triggs presented at CVPR 2005 for detecting people.

slide-28
SLIDE 28

Image Features: HoG

Paper by Navneet Dalal & Bill Triggs presented at CVPR 2005 for detecting people. Figure from Zhuolin Jiang, Zhe Lin, Larry S. Davis, ICCV 2009 for human action recognition.

+ Block Normalization

slide-29
SLIDE 29

Image Features: GIST

The “gist” of a scene: Oliva & Torralba, 2001

slide-30
SLIDE 30

Image Features: GIST

Oriented edge response at multiple scales (5 spatial scales, 6 edge orientations)

Hays and Efros, SIGGRAPH 2007

slide-31
SLIDE 31

Image Features: GIST

Aggregated edge responses over 4x4 windows

Hays and Efros, SIGGRAPH 2007

slide-32
SLIDE 32

Image Features: Bag of (Visual) Words Representation

slide by Fei-fei Li

slide-33
SLIDE 33

slide by Fei-fei Li

slide-34
SLIDE 34

Questions?

34