Sparse Coding Arthur Pece [email protected]. Outline Generative-model-based vision Linear,...

40
Sparse Coding Arthur Pece [email protected]

Transcript of Sparse Coding Arthur Pece [email protected]. Outline Generative-model-based vision Linear,...

Page 1: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

Sparse CodingArthur Pece

[email protected]

Page 2: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

Outline

Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method of

Olshausen+Field & Harpur+Prager Matching pursuit The inhibition method An application to medical images A hypothesis about the brain

Page 3: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

Generative-Model-Based Vision

Generative models Bayes’ theorem (gives an objective function) Iterative optimization (for parameter estimation) Occam’s razor (for model selection)

A less-fuzzy definition of model-based vision.Four basic principles (suggested by the speaker):

Page 4: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

Why?

A generative model and Bayes’ theorem lead to a better understanding of what the algorithm is doing

When the MAP solution cannot be found analytically, iterating between top-down and bottom-up becomes necessary (as in EM, Newton-like and conjugate-gradient methods)

Models should not only be likely, but also lead to precise predictions, hence (one interpretation of) Occam’s razor

Page 5: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

Linear Generative Models

x is the observation vector (n samples/pixels) s is the source vector (m sources) A is the mixing matrix (n x m) n is the noise vector (n dimensions)

The noise vector is really a part of the source vector

x = A.s + n

Page 6: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

Learning vs. Search/Perception

Learning: given an ensemble X = {x i},

maximize the posterior probability of the

mixing matrix A Perception: given an instance x,

maximize the posterior probability of the

source vector s

x = A.s + n

Page 7: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

MAP Estimation

From Bayes’ theorem:

log p(A | X) = log p(X | A) + log p(A) - log p(X)

(marginalize over S)

log p(s | x) = log p(x | s) + log p(s) - log p(x)

(marginalize over A)

Page 8: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

Statistical independence of the sources

Why is A not the identity matrix ? Why is p(s) super-Gaussian (lepto-kurtic)? Why m>n ?

Page 9: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

Why is A not the identity matrix?

Pixels are not statistically independent:

log p(x) /= Σ log p(x i)

Sources are (or should be) statistically independent:

log p(s) = Σ log p(s j)

Thus, the log p.d.f. of images is equal to the sum of the log p.d.f.’s of the coefficients,NOT equal to the sum of the log p.d.f.’s of the pixels.

Page 10: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

Why is A not the identity matrix?(continued)

From the previous slide:

Σ log p(c j) /= Σ log p(x i)

But, statistically, the estimated probability of an image is higher if the estimate is given by the sum of coefficient probabilities, rather than the sum of pixel probabilities:

E [ Σ log p(c j) ] > E [ Σ log p(x i) ]This is equivalent to:

H [ p(c j)] < H [ p(x i)]

Page 11: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

Why m>n ?

Why is p(s) super-Gaussian?The image “sources” are edges; ultimately, objects Edges can be found at any image location and can

have any orientation and intensity profile Objects can be found at any location in the scene

and can have many different shapes Many more (potential) edges or (potential) objects

than pixels Most of these potential edges or objects are not

found in a specific image

Page 12: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

Linear non-Gaussian generative model

Super-Gaussian prior p.d.f. of sources Gaussian prior p.d.f. of noise

log p(s | x,A) = log p(x | s,A) + log p(s) – log p(x | A)

log p(x | s,A) = log p(x - A.s) = log p(n)= - n.n/(2σ2) - log Z= - || x - A.s ||2/(2σ2) - log Z

Page 13: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

Linear non-Gaussian generative model (continued)

Example: Laplacian p.d.f. of sources:log p(s) = - Σ |s| / λ - log Q

log p(s | x,A) = log p(x | s,A) + log p(s) – log p(x | A) = - || x - A.s ||2 /(2σ2)

- Σ |s| / λ - const.

Page 14: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

Summary

Generative-model-based vision Learning vs. Perception Over-complete expansions Sparse prior distribution of sources Linear over-complete generative model with

Laplacian prior distribution for the sources

Page 15: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

The Penalty Method: Coding

Gradient-based optimization of the log-posterior probability of the coefficients

(d/ds) log p(s | x) = - AT .(x - A.s) / σ2 - sign(s) / λ

Note: as the noise variance tends to zero, the quadratic term dominates the right-hand sideand the MAP estimate could be obtained by solvinga linear system.However, if m>n then minimizing a quadratic objective function would spread the image energy over non-orthogonal coefficients

Page 16: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

Linear inferencefrom linear generative modelswith Gaussian prior p.d.f.

The logarithm of a multivariate Gaussian is a weighted sum of squares

The gradient of a sum of squares is a linear function

The MAP solution is the solution of a linear system

Page 17: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

Non-linear inferencefrom linear generative modelswith non-Gaussian prior p.d.f.

The logarithm of a multivariate non-Gaussian p.d.f. is NOT a weighted sum of squares

The gradient of a non-Gaussian p.d.f. is NOT a linear function

The MAP solution is NOT the solution of a linear system: in general, no analytical solution exists (this is why over-complete bases are not popular)

Page 18: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

PCA, ICA, SCA

PCA generative model: multivariate Gaussian

-> closed-form solution ICA generative model: non-Gaussian

-> iterative optimization over image ensemble SCA generative model:

over-complete non-Gaussian

-> iterate for each image for perception, over the image ensemble for learning

Page 19: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

The Penalty Method: Learning

Gradient-based optimization of the log-posterior probability* of the mixing matrix

Δ A = - A (z . cT + I)

where

z j = (d/dsj ) log p(sj )

and c is the MAP estimate of s

* actually log-likelihood

Page 20: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

Summary

Generative-model-based vision Learning vs. Perception Over-complete expansions Sparse prior distribution of sources Linear over-complete generative model with

Laplacian prior distribution for the sources Iterative coding as MAP estimation of sources Learning an over-complete expansion

Page 21: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

Vector Quantization

General VQ: K-means clustering of signals/images

Shape-gain VQ: clustering on the unit sphere

(after a change from Cartesian to polar coordinates)

Iterated VQ: iterative VQ of the residual signal/image

Page 22: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

Matching Pursuit

Iterative shape-gain vector quantization: Projection of the residual image onto all

expansion images Selection of the largest (in absolute value)

projection Updating of the corresponding coefficient Subtraction of the updated component from the

residual image

Page 23: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

Inhibition Method

Similar iteration structure, but more than one coefficient updated per iteration:

Projection of the residual image onto all expansion images

Selection of the largest (in absolute value) k projections Selection of orthogonal elelemnts in this reduced set Updating of the corresponding coefficients Subtraction of the updated components from the

residual image

Page 24: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

2404/19/23

MacKay Diagram

Page 25: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

Selection inMatching Pursuit

Page 26: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

Selection in the Inhibition Method

Page 27: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

2704/19/23

Encoding natural images: Lena

Page 28: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

2804/19/23

Encoding natural images: a landscape

Page 29: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

2904/19/23

Encoding natural images: a bird

Page 30: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

Comparison to the penalty method

Page 31: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

Visual comparisons

JPEG inhibition method penalty method

Page 32: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

Expanding the dictionary

Page 33: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

An Application to Medical Images

X-ray images decomposed by means of matching pursuit

Image reconstruction by optimally re-weighting the components obtained by matching pursuit

Thresholding to detect micro-calcifications

Page 34: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

3404/19/23

Tumor detection in mammograms

Page 35: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

Residual image after several matching pursuit iterations

Page 36: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

Image reconstructed from matching-pursuit components

Page 37: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

Weighted reconstruction

Page 38: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

Receiver Operating Curve

Page 39: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

A Hypothesis about the Brain

Some facts All input to the cerebral cortex is relayed

through the thalamus: e.g. all visual input from the retina is relayed through the LGN

Connections between cortical areas and thalamic nuclei are always reciprocal

Feedback to the LGN seems to be negativeHypothesis: cortico-thalamic loops minimize

prediction error

Page 40: Sparse Coding Arthur Pece aecp@cs.rug.nl. Outline Generative-model-based vision Linear, non-Gaussian, over-complete generative models The penalty method.

Additional references

Donald MacKay (1956) D Field (1994) Harpur and Prager (1995) Lewicki and Olshausen (1999) Yoshida (1999)