48
04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University 1 Image: http://darksideoftheca talogue.wordpress.com/ 2011/11/22/light-at- the-end-of-the-tunnel- is-glowing-thing-23-

04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig

Embed Size (px)

Citation preview

Page 1: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig

04/30/13

Last class: summary, goggles, ices

Discrete Structures (CS 173)Derek Hoiem, University of Illinois 1

Image: http://darksideofthecatalogue.wordpress.com/2011/11/22/light-at-the-end-of-the-tunnel-is-glowing-thing-23-12/

Page 2: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig

Final examTuesday, May 7, 7-10pm

DCL 1320: Students with last names Afridi to Mehta

Siebel 1404: Students with last names Melvin to Zmick

You should have already contacted us about conflicts. Note there is no specific conflict exam --- most conflicts should be resolved by other classes unless due to 3 tests in one day.http://admin.illinois.edu/policy/code/article3_part2_3-201.html

2

Page 3: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig

What to expect on final• Focus on material after midterm 2, but will be

stuff from earlier parts of semester also• Almost certainly at least one question on each

of:– Big-O/Algorithms– Proof by Contradiction– State Diagrams– Induction– Countability (not too complicated)

3

Page 4: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig

Today’s class

• Summary of concepts learned

• Fast image retrieval, Google Goggles, and the relevance to discrete structures

• ICES forms

4

Page 5: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig

What you learned in CS 173

• How to model the world

• How to prove things

• How to model computational behavior

• How to think formally and computationally

5

Page 6: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig

How to model the world• Logic, propositions, and relations

– Used in natural language processing, machine learning, programming languages

• Sets– Used for data mining, groups (e.g., with social networks), image processing (e.g.,

sets of pixels), clustering

• Functions, algorithms– Programming languages, most programming

• Graphs and trees– Used in search, machine learning, social networks, path planning, menu design

• State diagrams– Used for design of automated systems, AI planning, map building, robotics

6

Page 7: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig

How to prove things

• Direct proof

• Use of cases

• Indirect proofs such as by contrapositive– Changing into logically equivalent form sometimes makes the proof easier

• Proof by example or counter-example– Useful to show something exists

• Induction– Proof for unbounded set of integers

• Contradiction– Useful to show something can’t exist

7

Page 8: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig

How to model computational behavior

• Algorithm analysis

• Recursion trees– Unroll recursive functions to analyze cost at root,

internal calls, and leaves

• Big-O and Big-Theta– Analyze running time independent of

implementation details and compute power8

Page 9: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig

How to think formally and computationally

• Formal proof methods

• Number theory– Important for numerical methods

• P vs. NP– Important classes of algorithms

• Comparing cardinality of infinite sets– Fundamental implications, such as halting problem

9

Page 10: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig

Google goggles

http://www.google.com/mobile/goggles/#text

Demo

10

Page 11: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig

How to quickly find images in a large database that match a given image?

Page 12: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig

Basic representation: interest points (also called keypoints)

Describe appearance of distinctive image patches

12

Thousands of these per image, each is a 128 dimension vector of numbers

Page 13: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig

Simple idea

See how many keypoints are close to keypoints in each other image

Lots of Matches

Few or No Matches

But this will be really, really slow!Like 10 images per second.

Page 14: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig

Slide Slide Credit: Nister

110,000,000 Images in 5.8 Seconds

“Scalable Recognition with a Vocabulary Tree”, Nister and Stewenius, CVPR 2006.

Page 15: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig

Slide Slide Credit: Nister

Page 16: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig

Slide Slide Credit: Nister

Page 17: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig

Slide Credit: NisterSlide

Page 18: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig

Structure 1: “Visual Words”

• Group points (descriptors) into sets of similar points (called “clustering”)

• Represent image as the number of points you see in each set– Images are similar if they have a lot of sets in common

• Concepts from class: a set of 128-dimensional real vectors is partitioned into sets, and new vectors are assigned to a set index:

Page 19: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig

K-means algorithm

Illustration: http://en.wikipedia.org/wiki/K-means_clustering

1. Randomly select K centers

2. Assign each point to nearest center

3. Compute new center (mean) for each cluster

Page 20: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig

K-means algorithm

1. Randomly select K centers

2. Assign each point to nearest center

3. Compute new center (mean) for each cluster

Back to 2

Demo: http://home.dei.polimi.it/matteucc/Clustering/tutorial_html/AppletKM.html

Page 21: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig

Efficiency from clustering

Time to match images in database:– Previous matching time for two images with

descriptors of dimensions– Post-cluster matching time:

Time to assign points to clusters:

21

Page 22: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig

Structure 2: trees for nested partitions

• For points within a set to be very similar, need many sets (1,000,000)– Slow time to assign points to sets– Need to compare each point to each cluster center:

• Solution: create nested sets

• Discrete structures concepts: collections of sets, trees

Following slides by David Nister (CVPR 2006)

Page 23: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig
Page 24: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig
Page 25: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig
Page 26: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig
Page 27: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig
Page 28: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig
Page 29: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig
Page 30: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig
Page 31: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig
Page 32: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig
Page 33: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig
Page 34: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig
Page 35: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig

Much faster processing of query image

Old time to assign points to sets: for clusters

New time with trees:

In practice: 10,000+ times speed up

35

Page 36: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig

Structure 3: Inverse document file

• Like a book index: keep a list of all the words (keypoints) and all the pages (images) that contain them.

• Rank database images based on tf-idf measure.

tf-idf: Term Frequency – Inverse Document Frequency

# words in document

# times word appears in document

# documents

# documents that contain the word

Page 37: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig
Page 38: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig
Page 39: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig
Page 40: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig
Page 41: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig
Page 42: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig

Performance

Page 43: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig

Speedups

• Matching based on set membership

• Tree for faster clustering

• Inverse document file for only checking images with same sets as query

• Overall (in practice 100,000+ times speedup)

Page 44: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig

Slide Slide Credit: Nister

110,000,000 Images in 5.8 Seconds

“Scalable Recognition with a Vocabulary Tree”, Nister and Stewenius, CVPR 2006.

Page 45: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig

Summary• Clever data structures and efficient algorithms

make the difference between 10 images per second and 20 million images per second– Clustering (partitioning) for faster comparison– Trees for faster clustering– Lookup table for faster matching

• In this class, you learned how to model, analyze, and prove things about discrete structures

45

Page 46: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig

Next steps

• CS 225: implementing and using data structures such as linked lists, trees, graphs, etc.

• CS 241/242: experience writing code and structuring programs and dealing with OS

• CS 373: grammars, finite automata, languages, Turing machines, decidability

• Research or project experience46

Page 47: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig

ICES forms• Important for course evaluation and feedback

• Please provide comments about both positive aspects and ways to improve

47

Page 48: 04/30/13 Last class: summary, goggles, ices Discrete Structures (CS 173) Derek Hoiem, University of Illinois 1 Image: . wordpress.com/2011/11/22/lig

Thank you!

48