Ordinary Least-Squares Emmanuel Iarussi Inria
Many graphics problems can be seen as finding the best set of parameters for a model, given some data Surface reconstruction 2
Color diffusion 3 Many graphics problems can be seen as finding the best set of parameters for a model, given some data
Shape registration 4 Many graphics problems can be seen as finding the best set of parameters for a model, given some data
Temperature (a)Gas pressure (b) Example: estimation of gas pressure for a given temperature sample 5
Assuming linear relationship 6
7
Temperature measurements (m) Pressure measurements (m) 8
Assuming linear relationship Temperature measurements (m) Pressure measurements (m) = 9
Assuming linear relationship The relationship might not be exact Temperature measurements (m) Pressure measurements (m) = 10
Assuming linear relationship The relationship might not be exact Temperature measurements (m) Pressure measurements (m) … = Match “as best as possible” the observations 11
Assuming linear relationship The relationship might not be exact Match “as best as possible” the observations Temperature measurements (m) Pressure measurements (m) = 12
Many of CG problems can be formulated as minimizing the sum of squares of the residuals between some features in the model and the data. or 13
Matrix notation (observations) We can rewrite the residual function using linear algebra as: 14
Temperature Gas pressure Example: estimation of gas pressure for a given temperature and altitude samples Altitude 15
Multidimensional linear regression, using a model with n parameters 16
Multidimensional linear regression, using a model with n parameters before + +… 17
Multidimensional linear regression, using a model with n parameters Temperature measurements (m) Pressure measurements (m) Altitude measurements (m) 18
Multidimensional linear regression, using a model with n parameters Temperature measurements (m) Pressure measurements (m) Altitude measurements (m) = 19
= 20
= 21
= 22
Objective: find x subject to minimize: 23
Objective: find x subject to minimize: 24
Objective: find x subject to minimize: Convex bowl function has minima when: 25
Objective: find x subject to minimize: Convex bowl function has minima when: gradient 26
Expanding square term 27
Expanding square term 28
Differentiating with respect to x (gradient) Expanding square term 29
Expanding square term Differentiating with respect to x (gradient) 30
Expanding square term Normal equation x = (A.transpose()*A).solve(A.transpose()*b); Differentiating with respect to x (gradient) 31
Expanding square term Normal equation x = (A.transpose()*A).solve(A.transpose()*b); Issue: matrix multiplication Differentiating with respect to x (gradient) 32
Differentiating with respect to x Expanding square term Normal equation x = (A.transpose()*A).solve(A.transpose()*b); Issue: matrix multiplication Solution: find expression 33
Let's go back to gradient = 0 34
Let's go back to gradient = 0 Differentiating again with respect to x 35
Let's go back to gradient = 0 Differentiating again with respect to x 36
Let's go back to gradient = 0 Differentiating again with respect to x hessian 37
Let's go back to gradient = 0 Differentiating again with respect to x hessian 38
Let's go back to gradient = 0 Differentiating again with respect to x x = (A.transpose()*A).solve(A.transpose()*b); Normal equation: 39
Let's go back to gradient = 0 Differentiating again with respect to x x = (A.transpose()*A).solve(A.transpose()*b); Normal equation: 40
Let's go back to gradient = 0 Differentiating again with respect to x x = (A.transpose()*A).solve(A.transpose()*b); x = (H).solve(c); Two alternatives for solving: Constant terms in gradient 41
Example: Diffusion 42
Example: Diffusion Minimize difference between neighbors … 43
Example: Diffusion Minimize difference between neighbors … 44
Example: Diffusion Minimize difference between neighbors … 45
Example: Diffusion Minimize difference between neighbors … 46
Solving with normal equation: … 1.Build A 47
Solving with normal equation: … 1.Build A 48
Solving with normal equation: … 1.Build A 49
Solving with normal equation: … 1.Build A 50
Solving with normal equation: … 1.Build A 51
Solving with normal equation: … 1.Build A 52
Solving with normal equation: 2. Compute and 53
Solving with normal equation: 3.Solve using: Cholesky decomposition Conjugate Gradient … x = (A.transpose()*A).solve(A.transpose()*b); in Eigen (i.e): 54
Solving with normal equation: 3.Solve using: Cholesky decomposition Conjugate Gradient … x = (A.transpose()*A).solve(A.transpose()*b); in Eigen (i.e): x wil have: 55
Solving with Hessian: 1. Gradient vector: first-order partial derivatives of energy terms 56
Solving with Hessian: 1. Gradient vector: first-order partial derivatives of energy terms 57
Solving with Hessian: 1. Gradient vector: first-order partial derivatives of energy terms 58
Solving with Hessian: 1. Gradient vector: first-order partial derivatives of energy terms 59
Solving with Hessian: 1. Gradient vector: first-order partial derivatives of energy terms 60
Solving with Hessian: 2. Hessian matrix: second-order partial derivatives of energy terms 61
Solving with Hessian: 2. Hessian matrix: second-order partial derivatives of energy terms 62
Solving with Hessian: 2. Hessian matrix: second-order partial derivatives of energy terms 63
Solving with Hessian: 2. Hessian matrix: second-order partial derivatives of energy terms 64
Solving with Hessian: 65
Solving with Hessian: 1. Gradient vector: first-order partial derivatives of energy terms 66
Solving with Hessian: 1. Gradient vector: first-order partial derivatives of energy terms 67
Solving with Hessian: 1. Gradient vector: first-order partial derivatives of energy terms 68
Solving with Hessian: 1. Gradient vector: first-order partial derivatives of energy terms 69
Solving with Hessian: 2. Hessian matrix: second-order partial derivatives of energy terms 70
Solving with Hessian: 2. Hessian matrix: second-order partial derivatives of energy terms 71
Solving with Hessian: 2. Hessian matrix: second-order partial derivatives of energy terms 72
Solving with Hessian: 2. Hessian matrix: second-order partial derivatives of energy terms 73
Solving with Hessian: 74
Solving with Hessian: To recap: 75
Solving with Hessian: 3. Build system … 76
Solving with Hessian: 3. Build system … 77
Solving with Hessian: 3. Build system: add constraint … 78
Solving with Hessian: … 3. Build system: add constraint 79
Solving with Hessian: … 3. Build system: add constraint 80
Solving with Hessian: … 3. Build system: add constraint 81
Solving with Hessian: … 3. Build system: add constraint 82
Solving with Hessian: … 3. Build system: add constraint 83
Solving with Hessian: … 3. Build system: add constraint 84
Solving with Hessian: … 3. Build system: add constraint 85
Solving with Hessian: … 3. Build system: add constraint 86
Solving with Hessian: 4. Solve using: Cholesky decomposition Conjugate Gradient … 87
Solving with Hessian: x = (H).solve(b`); in Eigen (i.e): x will have: 4. Solve using: Cholesky decomposition Conjugate Gradient … 88
References: 89 Solving Least Squares Problems. C. L. Lawson and R. J. Hanson Practical Least Squares for Computer Graphics. Fred Pighin and J.P. Lewis. Course notes 2007.