59
Discrete Inference and Learning Lecture 4 MVA 2020 – 2021 http://thoth.inrialpes.fr/~alahari/disinflearn Slides based on material from Nikos Komodakis, M. Pawan Kumar

Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

DiscreteInferenceandLearningLecture4

MVA2020–2021

http://thoth.inrialpes.fr/~alahari/disinflearn

SlidesbasedonmaterialfromNikosKomodakis,M.PawanKumar

Page 2: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

Outline

•  Previousclasses– Graphcuts,Beliefpropagationandvariants–  (Inference)

•  Today– Quickrecapofthecourse– Learningparameters

Page 3: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

Beforemovingon…

Page 4: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

Projectsuggestions(alsosentbyemail)

•  ImplementBPontrees,thengraph,extendtoTRW,compare•  Implementgraphcut+extension(Ishikawa,othermulti-label)or

variationofimplementation+smallapplication•  Complexapplicationofgraphcut,requiringmodelling(e.g.,

sequenceofimages)•  Geometricscenelabellingwithgraphcuts•  Jointmodellingoftwolabellingproblems(e.g.,segmentation+

detection)•  Implementfastprimal-dualalgorithm+evaluate•  Implementdeformablepartsmodelforobjectdetection•  …•  Oryourown(butcheckwithusfirst)•  Selectprojectsbefore25thJanuaryandemailus

([email protected],[email protected])

Page 5: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

Projects

•  Chooseprojectsbefore25/1(Monday!)

•  Presentationson31/3–  InEnglishorFrench– 15min,includingquestions

•  Reportdueon30/3

Page 6: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

Recap

•  Whatinferencealgorithmwouldyouusefor– agraphwithonlychains•  2-labelproblem?•  Multi-labelproblem?

– Treestructuredgraph•  2labelproblem?•  Multi-labelproblem?

Page 7: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

Recap•  Basics:problemformulation– EnergyFunction– MAPEstimation– Computingmin-marginals– Reparameterization

•  Solutions– BeliefPropagationandrelatedmethods[Lecture3]– Graphcuts[Lecture2]

Page 8: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

Outline

•  Recapofthecourse

•  Learningparameters

Page 9: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

ConditionalRandomFields(CRFs)•  Ubiquitousincomputervision•  segmentation stereomatchingopticalflow imagerestorationimagecompletion objectdetection/localization...

•  andbeyond•  medicalimaging,computergraphics,digitalcommunications,physics…

•  Reallypowerfulformulation

Page 10: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

ConditionalRandomFields(CRFs)

•  Extensiveresearchformorethan20years

•  Keytask:inference/optimizationforCRFs/MRFs

•  Lotsofprogress

•  Graph-cutbasedalgorithms•  Message-passingmethods•  LPrelaxations•  DualDecomposition•  ….

•  Manystate-of-the-artmethods:

Page 11: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

MAPinferenceforCRFs/MRFs

•  Hypergraph– Nodes– Hyperedges/cliques

•  High-orderMRFenergyminimizationproblem

high-orderpotential(oneperclique)

unarypotential(onepernode)

hyperedges

nodes

Page 12: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

CRFtraining•  ButhowdowechoosetheCRFpotentials?

•  Throughtraining•  Parameterizepotentialsbyw

•  Usetrainingdatatolearncorrectw

•  Characteristicexampleofstructuredoutputlearning[Taskar],[Tsochantaridis,Joachims]

•  Equally,ifnotmore,importantthanMAPinference•  Betteroptimizecorrectenergy(evenapproximately)•  Thanoptimizewrongenergyexactly

Page 13: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

•  SupervisedLearning

•  ProbabilisticMethods

•  Loss-basedMethods

•  Results

Outline

Page 14: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

ImageClassification

Isthisanurbanorruralarea?

Input:d Output:x∈{-1,+1}

Page 15: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

ImageClassification

Isthisscanhealthyorunhealthy?

Input:d Output:x∈{-1,+1}

Page 16: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

ImageClassification

X

d

LabelingX=x LabelsetL={-1,+1}

Page 17: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

ImageClassification

Whichcityisthis?

Input:d Output:x∈{1,2,…,h}

Page 18: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

ImageClassification

Whattypeoftumordoesthisscancontain?

Input:d Output:x∈{1,2,…,h}

Page 19: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

ObjectDetection

Whereistheobjectintheimage?

Input:d Output:x∈{Pixels}

Page 20: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

ObjectDetection

Whereistheruptureinthescan?

Input:d Output:x∈{Pixels}

Page 21: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

ObjectDetection

X

d

LabelingX=x LabelsetL={1,2,…,h}

Page 22: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

Segmentation

Whatisthesemanticclassofeachpixel?

Input:d Output:x∈{1,2,…,h}|Pixels|

car

roadgrass

treesky

sky

Page 23: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

Segmentation

Whatisthemusclegroupofeachpixel?

Input:d Output:x∈{1,2,…,h}|Pixels|

Page 24: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

Segmentation

X1

d1

X2

d2

X3

d3

X4

d4

X5

d5

X6

d6

X7

d7

X8

d8

X9

d9

LabelingX=x LabelsetL={1,2,…,h}

Page 25: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

Segmentation

X1

d1

X2

d2

X3

d3

X4

d4

X5

d5

X6

d6

X7

d7

X8

d8

X9

d9

LabelingX=x LabelsetL={1,2,…,h}

Page 26: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

CRFtraining•  Stereomatching:•  Z:left,rightimage•  X:disparitymap

Z X

f :

argf = parameterizedbyw

Goaloftraining:estimateproper

w

Page 27: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

CRFtraining•  Denoising:•  Z:noisyinputimage•  X:denoisedoutputimage

Z X

f :

argf = parameterizedbyw

Goaloftraining:estimateproper

w

Page 28: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

CRFtraining•  Objectdetection:•  Z:inputimage•  X:positionofobjectparts

Z X

f :

argf = parameterizedbyw

Goaloftraining:estimateproper

w

Page 29: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

CRFtraining(somefurthernotation)

vectorvaluedfeaturefunctions

Page 30: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

Learningformulations

Page 31: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

Riskminimization

Ktrainingsamples

Page 32: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

RegularizedRiskminimization

Page 33: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

RegularizedRiskminimization

ReplaceΔ(.)witheasiertohandleupperboundLG(e.g.,convexw.r.t.w)

Page 34: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

Choice1:Hingeloss

§  UpperboundsΔ(.)

§  Leadstomax-marginlearning

Page 35: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

Max-marginlearning

energyofgroundtruth

anyotherenergy

desiredmargin

slack

Page 36: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

Max-marginlearning

subjecttotheconstraints:

energyofgroundtruth

anyotherenergy

desiredmargin

slack

Page 37: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

Max-marginlearning

subjecttotheconstraints:

energyofgroundtruth

anyotherenergy

desiredmargin

slack

Page 38: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

Max-marginlearning

subjecttotheconstraints:

orequivalently

CONSTRAINED

UNCONSTRAINED

Page 39: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

Choice2:logisticloss

§  Canbeshowntoleadtomaximumlikelihoodlearning

partitionfunction

Page 40: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

Max-marginvsMaximum-likelihoodmax-margin

maximumlikelihood

Page 41: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

Max-marginvsMaximum-likelihoodmax-margin

maximumlikelihood

soft-max

Page 42: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

Solvingthelearningformulations

Page 43: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

Maximum-likelihoodlearning

§  Differentiable&convex

partitionfunction

§  Globaloptimumviagradientdescent,forexample

Page 44: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

Maximum-likelihoodlearning

gradient

Recallthat:

Page 45: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

Maximum-likelihoodlearning

gradient

§  RequiresMRFprobabilisticinference§  NP-hard(exponentiallymanyx):approximationvialoopy-BP?

Page 46: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

Max-marginlearning(UNCONSTRAINED)

§  Convexbutnon-differentiable§  Globaloptimumviasubgradientmethod

Page 47: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

Subgradient

x2

subgradientatx1

g(x2)+h2·(x-x2)

subgradientatx2=gradientatx2

Page 48: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

Subgradient

Page 49: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

Subgradient

x

Page 50: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

Subgradient

subgradientofLG =

Page 51: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

Max-marginlearning(UNCONSTRAINED)

totalsubgr. =

Repeat1.computeglobalminimizersatcurrentw 2.computetotalsubgradientatcurrentw3.updatew bytakingastepinthenegativetotalsubgradient direction

untilconvergence

Subgradientalgorithm

Page 52: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

Max-marginlearning(UNCONSTRAINED)

partialsubgradient=

Repeat1.pickkatrandom2.computeglobalminimizeratcurrentw 3.computepartialsubgradientatcurrentw4.updatew bytakingastepinthenegativepartialsubgradient direction

untilconvergence

Stochasticsubgradientalgorithm

MRF-MAPestimationperiteration(unfortunatelyNP-hard)

Page 53: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

Max-marginlearning(CONSTRAINED)

subjecttotheconstraints:

Page 54: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

Max-marginlearning(CONSTRAINED)

subjecttotheconstraints:

linearinw

•  Quadraticprogram(great!)•  Butexponentiallymanyconstraints(notsogreat)

Page 55: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

•  Whatifweuseonlyasmallnumberofconstraints?

•  ResultingQPcanbesolved•  Butsolutionmaybeinfeasible

Max-marginlearning(CONSTRAINED)

•  onlyfewconstraintsactiveatoptimalsolution!!(variablesmuchfewerthanconstraints)

•  Constraintgenerationtotherescue

•  Giventheactiveconstraints,restcanbeignored•  Thenletustrytofindthem!

Page 56: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

1.Startwithsomeconstraints

Constraintgeneration

2.SolveQP

3.Checkifsolutionisfeasiblew.r.t.toallconstraints

4.Ifyes,wearedone!

5.Ifnot,pickaviolatedconstraintandaddittothecurrentsetofconstraints.Repeatfromstep2.(optionally,wecanalsoremoveinactiveconstraints)

Page 57: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

•  Keyissue:wemustalwaysbeabletofindaviolatedconstraintifoneexists

Constraintgeneration

•  Recalltheconstraintsformax-marginlearning

•  Tofindviolatedconstraint,wethereforeneedtocompute:

(justlikesubgradientmethod!)

Page 58: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

1.InitializesetofconstraintsC toempty

Constraintgeneration

2.SolveQPusingcurrentconstraintsC andobtainnew(w,ξ)

4.Foreachk,ifthefollowingconstraintisviolatedthenaddittosetC:

5.Ifnonewconstraintwasaddedthenterminate.Otherwisegotostep2.

3.Computeglobalminimizersatcurrentw

MRF-MAPestimationpersample(unfortunatelyNP-hard)

Page 59: Discrete Inference and Learning Lecture 4thoth.inrialpes.fr/~alahari/disinflearn/20-21-Lecture04.pdfProject suggestions (also sent by email) • Implement BP on trees, then graph,

Max-marginlearning(CONSTRAINED)

subjecttotheconstraints:

•  Alternatively,wecansolveaboveQPinthedualdomain

•  dualvariables↔primalconstraints•  Toomanyvariables,butmostofthemzeroatoptimalsolution

•  Useaworking-setmethod(essentiallydualtoconstraintgeneration)