anthony gruber calculus for computer graphics and data science
TRANSCRIPT
![Page 1: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/1.jpg)
Anthony Gruber
Calculus for Computer Graphics and Data Science
![Page 2: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/2.jpg)
Outline
❖ Motivation: Why calculus?
❖ Calculus in Artificial Neural Networks
❖ How do they learn?
❖ Calculus in Curvature Flows
❖ How does deformation work?
![Page 3: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/3.jpg)
Motivation
❖ Animation & Simulation
❖ Often want continuous change.
❖ Calculus is the study of continuous change!
❖ Gruber, A. and Aulisa, E. ACM Trans. Graph. (2020)
![Page 4: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/4.jpg)
Motivation
❖ Quantitative change must be prescribed.
❖ Pictured: solving a differential equation.
❖ (Certain curvature is minimized over time.)
❖ Gruber, A. and Aulisa, E. ACM Trans. Graph. (2020)
![Page 5: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/5.jpg)
Motivation
❖ Consider artificial neural networks (ANNs).
❖ ANNs change to learn a predefined task.
❖ Learn by decreasing error as fast as possible.
“Zero”
“One”
“Two”
“Three”
“Zero”
“One”
“Five”
“Eight”
Untrained Trained
![Page 6: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/6.jpg)
What is a Neural Network?
• A function approximation machine loosely modeled on biological systems.
• Each layer contains neurons (nodes) with learnable parameters (edge weights).
• # Nodes = Width, # Layers = Depth
![Page 7: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/7.jpg)
How do NNs Learn?
• Information flows forward from inputs to outputs.
• Outputs produce a response, with associated error.
• Information flows backward through derivative of error.
• Parameters are updated accordingly.
![Page 8: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/8.jpg)
Review: What is a Derivative?
❖ differentiable. Fix .
❖ Rate of change:
.
f : ℝ → ℝx ∈ ℝ
f′ (x) = limh→0
f(x + h) − f(x)h Ex) around f(x) = sin x x = π
4
![Page 9: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/9.jpg)
Review: What is a Derivative?
❖
❖ best linear approximation to at .
❖ is slope of tangent line to graph.
f(x + h) = f(x) + f′ (x)h + &(h2)= Tx(h) + &(h2)
Tx(h)f x
f′ (x)Ex) around f(x) = sin x x = π
4
![Page 10: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/10.jpg)
Review: What is a Derivative?
❖ How can we decrease
❖ Roll along the tangents
❖ Fact:
❖ (for small h)
❖ Eventually converges to local minimum.
f ?
xn+1 = xn − f′ (xn)h
Ex) around f(x) = sin x x = π4
![Page 11: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/11.jpg)
Gradient Descent
❖ Consider .
❖ gradient field (column vector)
❖ The maximum rate of change in occurs in the direction of .
❖ Therefore, decreases maximally when pushed in the direction of .
f : ℝn → ℝ∇f(x)
f∇f
f−∇f
Video by Jacopo Bertolottihttps://commons.wikimedia.org/wiki/File:Gradient_descent.gif
![Page 12: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/12.jpg)
Inside a Neural Network
❖ Consider a neural network .
❖ Depends on inputs and parameters .
❖ Consider a loss (error) function .
❖ What is ?
y = f(x, θ)x
θ
L(y)
Lθ(y) = ∂L∂θ
(y)
![Page 13: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/13.jpg)
Inside a Neural Network
❖ Components of : sensitivities of loss to each parameter .
❖ Chain rule!
❖
LθL θi
Lθ = L′ (y)yθ
Lθ = Ly1 y1θ + Ly2 y2
θ + Ly3 y3θ
![Page 14: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/14.jpg)
Neural Network Training
❖ What does the network do with this information?
❖ Value of decreases fastest when moves parallel to .
❖ (row version of gradient)
❖ Can update where is the learning rate.
Lθ −Lθ
θ ← θ − t L′ (y)yθt
![Page 15: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/15.jpg)
Example
❖ Consider
❖ Can we learn it?
❖ Take ,
❖ Network
❖Minimize
y = sin x + cos 2x
xi ∈ [0,2π] yi = sin xi + cos 2xi
f(x, θ)
L = ∑i
yi − f(xi, θ)2
![Page 16: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/16.jpg)
Graphics Applications
❖ The derivative is inherently linked to minimization.
❖ Willmore energy:
❖ How can we minimize such functions?
*2(X) = ∫MH2 dμg
![Page 17: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/17.jpg)
Review: What is a Derivative?
❖ What does do to the number
❖ The map is multiplication!
❖ The derivative dilates .
❖ for all .
f′ (x) h?h ↦ f′ (x)h
f′ (x) : ℝ → ℝh
f′ (x) = 0 ⟺ f′ (x)h = 0 h ∈ ℝ
h
f′ (x)h
![Page 18: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/18.jpg)
Example: Shortest length
❖ Curve .
❖ Length functional is
❖ variation of curve.
x : [0,1] → ℝ2
ℒ(x) = ∫Cds = ∫
1
0|x′ (t) | dt
x(t, τ) = x(t) + τ φ(t)
![Page 19: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/19.jpg)
First Variation of Length
❖ Want to find where is stationary.
❖ Means
.
❖ Must hold for all admissible .
❖ This is called taking the first variation of .
x ℒ
δℒ(x)φ = ddτ τ=0
ℒ(x + τ φ) = 0
φ
ℒ
![Page 20: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/20.jpg)
Example: Shortest length❖ When is stationary?
❖ .
❖ If , this implies
❖ for all .
❖ Curvature must be 0!
ℒddτ τ=0
ℒ(x + τ φ) = 0
φ(0) = φ(1) = 0
∫1
0κ N ⋅ φ dt = 0 φ
κ
![Page 21: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/21.jpg)
Derivative of Length Functional
❖ This shows is the gradient of the length.
❖ What if we solve
❖ Curve-shortening flow!
❖ Fastest way to decrease length.
κ N
·x = − κ N
![Page 22: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/22.jpg)
Curve-Shortening Flow
Code by Anthony Carapetis: https://github.com/acarapetis/
curve-shortening-demo
![Page 23: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/23.jpg)
What About in 2-D?
❖ Can you do the same in higher dimensions?
❖ Yes! Mean curvature flow .
❖ Fastest way to decrease surface area.
·X = ΔgX = − 2HN
![Page 24: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/24.jpg)
Geometry on a Surface
❖ How do we measure distances on
❖ We need a Riemannian metric .
❖ measures the angle between tangent vectors!
M?
g
g
![Page 25: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/25.jpg)
Geometry on a Surface
❖ gives a shape for .
❖ Using linearity,
❖ Then,
gx(u, v) = X′ (x)u ⋅ X′ (x)vM
gij = X′ ∂i ⋅ X′ ∂j = Xi ⋅ Xj
gx(u, v) = ∑ij
gij uivj = u⊤Gv
![Page 26: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/26.jpg)
Example
❖ .
❖
❖
X(x1, x2) = (x1 x2 −x21 − x2
2)⊤
X′ (x1, x2) =1 00 1
−2x1 −2x2
G = (1 + 4x21 4x1x2
4x1x2 1 + 4x22)
![Page 27: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/27.jpg)
What is the Mean Curvature?
❖ is an extrinsic measure of how bends in .
❖ Depends on how changes, i.e. .
❖ Eigenvalues of are the principal curvatures .
❖ .
H Mℝ3
NN′ : TM → T12
−N′
κ1, κ2
H = (1/2)(κ1 + κ2)
![Page 28: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/28.jpg)
What is Mean Curvature Flow?
❖ Extend to a variation , .
❖ is the velocity field of the variation .
❖ Consider the area functional:
.
❖ How does change as we change ?
X = X0 X : M × ℝ → ℝ3 X = X0 + t φ
φ : M → ℝ3 X
3(X) = ∫M1 dμg
3 t
![Page 29: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/29.jpg)
First Variation of Area
❖ We write .
❖ Since , one can show
❖ Change in area is proportional to mean curvature!
δ3(X0)φ = ddt t=0
3(X0 + tφ)
dμg = det G dA
δ3(X)φ = ∫M2H N ⋅ φ dμg
![Page 30: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/30.jpg)
Willmore Energy
❖ Another popular functional for graphics applications.
❖Willmore energy: .
❖ Conformal invariant (hard for analysis)
❖ Qualitatively: measures roundness.
*2(X) = ∫MH2 dμg
*2
![Page 31: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/31.jpg)
Willmore Flow❖ Need to solve
❖ Suppose is closed. New variable (G. Dziuk, 2012).
❖Weak definition .
❖ Willmore flow becomes coupled pair of -order PDEs for .
❖ (G., Aulisa) Extended ideas to p-Willmore energy.
·X ⋅ N = ΔgH + 2H(H2 − K)
M Y := ΔgX
∫MY ⋅ ψ + ⟨X′ ⋅ ψ′ ⟩g = 0
2nd
X
![Page 32: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/32.jpg)
Problems with Moving Domains
❖ Mesh can degenerate!
❖ Need some way to stop this…
![Page 33: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/33.jpg)
What about the Mesh?❖ Can consider least-
squares conformal mapping.
❖ Map is conformal if it preserves angles.
❖ When , equiv. to s.t. (Kamberov, Pedit, Pinkall 1996).
f : (M, g) → ℝ3
f : M → ℝ3
∃ N ⋆ df = N × df
![Page 34: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/34.jpg)
Results❖ Can minimize
integral of
with constraint.
❖ Yields least-squares conformal maps
❖ Makes triangulations much nicer.
| ⋆ dX − N × dX |2
![Page 35: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/35.jpg)
Trefoil Knot Unwinding
![Page 36: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/36.jpg)
Comparison: p-Willmore
❖ Volume-constrained flows.
❖ Higher p — more rounding behavior.
❖ Can show that p > 2 Willmore minimizers resemble minimal surfaces in some aspects. *
* Gruber, A., Toda M., Tran, H. Ann. Glob. Anal. Geom. (2019).
* Gruber, A., Pampano, A., Toda, M. Ann. Mat. Pura. Appl. (2021).
![Page 37: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/37.jpg)
Influence of the Constraint
Volume preserving 2-Willmore flow Volume and area preserving 2-Willmore flow
![Page 38: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/38.jpg)
A Problem with LSCM?
❖ Not so good for mappings with boundary correspondence.
❖ Conformal mappings are too restrictive for this.
![Page 39: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/39.jpg)
Conformal vs. Quasiconformal❖ Must allow bounded shearing distortion.
❖ In quaternionic setting, this means:
❖
❖ (anticonformal/conformal parts).
❖ Conformal iff Beltrami coefficient.
❖ is conjugate-dual to the Hopf differential .
df − = μ df +
μ = 0μ
Q = df +df −
df ± = 12 (df ∓ N ⋆ df)
![Page 40: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/40.jpg)
Comparison: TM vs. LSCM
❖ Gruber, A. and Aulisa, E. 2021 (under review)
![Page 41: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/41.jpg)
Computing TM mappings
❖ Minimize
alternatively over .
❖ 1) Minimize for given .
❖ 2) Compute .
❖ 3) Locally adjust , moving it toward TM form (next slide)
❖ Repeat steps 1-3 until convergence.
9:( f ) = ∫M|df − − μ df + |2 dμg
f, μ
f μ
μ = df − (df +)−1
μ
![Page 42: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/42.jpg)
Why does it work?
❖ Dirichlet energy w.r.t. any metric decomposes into area functional and conformal distortion.
❖ Can show that is the conformal part of .
❖ (Metric induced by QC mapping with BC .)
9:( f ) ;g(μ)( f )
g(μ) μ
;g( f ) = ∫M|df |2 = ∫M
|df + |2 − |df − |2 + 2∫M|df − |2 = 3( f ) + 2:;( f )
![Page 43: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/43.jpg)
More Examples
![Page 44: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/44.jpg)
Conclusions
❖ Many popular technologies rely on continuous change.
❖ Quantitatively, change must be prescribed.
❖ Often done through minimization of an appropriate function.
❖ If you want to be a scientist… Pay attention in calculus class!
![Page 45: Anthony Gruber Calculus for Computer Graphics and Data Science](https://reader035.vdocuments.us/reader035/viewer/2022081415/629de759ad0a8f36f71f78bc/html5/thumbnails/45.jpg)
Thank You!