├── .gitignore ├── Julia ├── 1dexamples.jl ├── 1dlaplacian.jl ├── comparisons.jl ├── earlystopping.jl ├── iterate.jl ├── laplacian.jl ├── momentum.jl ├── momentum2.jl ├── noisy_gradients.jl ├── pde.jl ├── poly2d.jl └── tem.jl ├── LICENSE ├── README.md ├── package.json ├── public ├── assets │ ├── data │ │ ├── Sigma.json │ │ ├── U.json │ │ ├── Urosen.json │ │ ├── Uval.json │ │ └── matrix.json │ ├── eigenfeatures.js │ ├── eigensum.js │ ├── flow.js │ ├── graph.js │ ├── index.html │ ├── iterates.js │ ├── lib │ │ ├── auto-render.min.js │ │ ├── contour_plot.js │ │ ├── contrib │ │ │ └── auto-render.min.js │ │ ├── d3-ring-note.js │ │ ├── fonts │ │ │ ├── KaTeX_AMS-Regular.eot │ │ │ ├── KaTeX_AMS-Regular.ttf │ │ │ ├── KaTeX_AMS-Regular.woff │ │ │ ├── KaTeX_AMS-Regular.woff2 │ │ │ ├── KaTeX_Caligraphic-Bold.eot │ │ │ ├── KaTeX_Caligraphic-Bold.ttf │ │ │ ├── KaTeX_Caligraphic-Bold.woff │ │ │ ├── KaTeX_Caligraphic-Bold.woff2 │ │ │ ├── KaTeX_Caligraphic-Regular.eot │ │ │ ├── KaTeX_Caligraphic-Regular.ttf │ │ │ ├── KaTeX_Caligraphic-Regular.woff │ │ │ ├── KaTeX_Caligraphic-Regular.woff2 │ │ │ ├── KaTeX_Fraktur-Bold.eot │ │ │ ├── KaTeX_Fraktur-Bold.ttf │ │ │ ├── KaTeX_Fraktur-Bold.woff │ │ │ ├── KaTeX_Fraktur-Bold.woff2 │ │ │ ├── KaTeX_Fraktur-Regular.eot │ │ │ ├── KaTeX_Fraktur-Regular.ttf │ │ │ ├── KaTeX_Fraktur-Regular.woff │ │ │ ├── KaTeX_Fraktur-Regular.woff2 │ │ │ ├── KaTeX_Main-Bold.eot │ │ │ ├── KaTeX_Main-Bold.ttf │ │ │ ├── KaTeX_Main-Bold.woff │ │ │ ├── KaTeX_Main-Bold.woff2 │ │ │ ├── KaTeX_Main-Italic.eot │ │ │ ├── KaTeX_Main-Italic.ttf │ │ │ ├── KaTeX_Main-Italic.woff │ │ │ ├── KaTeX_Main-Italic.woff2 │ │ │ ├── KaTeX_Main-Regular.eot │ │ │ ├── KaTeX_Main-Regular.ttf │ │ │ ├── KaTeX_Main-Regular.woff │ │ │ ├── KaTeX_Main-Regular.woff2 │ │ │ ├── KaTeX_Math-BoldItalic.eot │ │ │ ├── KaTeX_Math-BoldItalic.ttf │ │ │ ├── KaTeX_Math-BoldItalic.woff │ │ │ ├── KaTeX_Math-BoldItalic.woff2 │ │ │ ├── KaTeX_Math-Italic.eot │ │ │ ├── KaTeX_Math-Italic.ttf │ │ │ ├── KaTeX_Math-Italic.woff │ │ │ ├── KaTeX_Math-Italic.woff2 │ │ │ ├── KaTeX_Math-Regular.eot │ │ │ ├── KaTeX_Math-Regular.ttf │ │ │ ├── KaTeX_Math-Regular.woff │ │ │ ├── KaTeX_Math-Regular.woff2 │ │ │ ├── KaTeX_SansSerif-Bold.eot │ │ │ ├── KaTeX_SansSerif-Bold.ttf │ │ │ ├── KaTeX_SansSerif-Bold.woff │ │ │ ├── KaTeX_SansSerif-Bold.woff2 │ │ │ ├── KaTeX_SansSerif-Italic.eot │ │ │ ├── KaTeX_SansSerif-Italic.ttf │ │ │ ├── KaTeX_SansSerif-Italic.woff │ │ │ ├── KaTeX_SansSerif-Italic.woff2 │ │ │ ├── KaTeX_SansSerif-Regular.eot │ │ │ ├── KaTeX_SansSerif-Regular.ttf │ │ │ ├── KaTeX_SansSerif-Regular.woff │ │ │ ├── KaTeX_SansSerif-Regular.woff2 │ │ │ ├── KaTeX_Script-Regular.eot │ │ │ ├── KaTeX_Script-Regular.ttf │ │ │ ├── KaTeX_Script-Regular.woff │ │ │ ├── KaTeX_Script-Regular.woff2 │ │ │ ├── KaTeX_Size1-Regular.eot │ │ │ ├── KaTeX_Size1-Regular.ttf │ │ │ ├── KaTeX_Size1-Regular.woff │ │ │ ├── KaTeX_Size1-Regular.woff2 │ │ │ ├── KaTeX_Size2-Regular.eot │ │ │ ├── KaTeX_Size2-Regular.ttf │ │ │ ├── KaTeX_Size2-Regular.woff │ │ │ ├── KaTeX_Size2-Regular.woff2 │ │ │ ├── KaTeX_Size3-Regular.eot │ │ │ ├── KaTeX_Size3-Regular.ttf │ │ │ ├── KaTeX_Size3-Regular.woff │ │ │ ├── KaTeX_Size3-Regular.woff2 │ │ │ ├── KaTeX_Size4-Regular.eot │ │ │ ├── KaTeX_Size4-Regular.ttf │ │ │ ├── KaTeX_Size4-Regular.woff │ │ │ ├── KaTeX_Size4-Regular.woff2 │ │ │ ├── KaTeX_Typewriter-Regular.eot │ │ │ ├── KaTeX_Typewriter-Regular.ttf │ │ │ ├── KaTeX_Typewriter-Regular.woff │ │ │ └── KaTeX_Typewriter-Regular.woff2 │ │ ├── katex.css │ │ ├── katex.js │ │ ├── katex.min.css │ │ ├── katex.min.js │ │ ├── lib.js │ │ └── template.v1.js │ ├── milestones.js │ ├── momentum.js │ ├── numjs.js │ ├── phasediagram.js │ ├── phasediagram_description.js │ ├── poly.js │ ├── stochastic_milestones.js │ ├── utils.js │ └── widgets.css ├── examples │ ├── 2dslider_widget.html │ ├── annotate.html │ ├── annotate_shan.html │ ├── banana_widget.html │ ├── change_basis_widget.html │ ├── eigenfeatures_widget.html │ ├── eigensum.html │ ├── eigensum2.html │ ├── eigensum3.html │ ├── flow_widget.html │ ├── force-layout.html │ ├── hozbar_widget.html │ ├── linear_transform.html │ ├── milestones_widget.html │ ├── milestones_widget_momentum.html │ ├── momentum_widget.html │ ├── offline_equation.html │ ├── phase_diagram.html │ ├── phase_diagram_description.html │ ├── poly_widget.html │ ├── rnn.html │ ├── rosen_widget.html │ └── sketch.html ├── index.html └── thumbnail.jpg └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.log -------------------------------------------------------------------------------- /Julia/1dexamples.jl: -------------------------------------------------------------------------------- 1 | #=Copyright (c) 2017 Gabriel Goh 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.=# 19 | 20 | # α = 0.076 21 | # β = 0.513 22 | 23 | α = 0.2 24 | β = 0.99 25 | x = 2 26 | y = 0 27 | X = zeros(100) 28 | for i = 1:100 29 | y = β*y - x 30 | x = x - α*y 31 | X[i] = x 32 | end 33 | figure(); plot(X,"k"); plot(X,"k."); xlabel(L"k"); ylabel(L"f(x)") -------------------------------------------------------------------------------- /Julia/1dlaplacian.jl: -------------------------------------------------------------------------------- 1 | #=Copyright (c) 2017 Gabriel Goh 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.=# 19 | 20 | n = 50 21 | κ = 1000 22 | A = SymTridiagonal(2*ones(n), -ones(n-1)) 23 | A = (κ-1)*A/4 + eye(n) 24 | cond(A) 25 | b = zeros(n); b[1] = (κ - 1)/4 26 | 27 | Λ, Q = eig(A) 28 | 29 | κ = Λ[1]/Λ[n] 30 | α = 2/(Λ[1] + Λ[end]) 31 | β = 0.98 32 | #β = 0 33 | 34 | # Function from momentum2.jl 35 | Z = cat(2,[ runmomentumcheat(A,b,i)[2] for i = 1:400]...) 36 | heatmap(Z) 37 | 38 | plot(b2) 39 | plot!(A\b) -------------------------------------------------------------------------------- /Julia/comparisons.jl: -------------------------------------------------------------------------------- 1 | #=Copyright (c) 2017 Gabriel Goh 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.=# 19 | 20 | # f(x) = ((1 + ((x[1]+x[2]+1)^2)*(19 - 14*x[1]+3*x[1]^2-14*x[2]+6*x[1]*x[2]+3*x[2]^2))* 21 | # (30 + ((2*x[1] - 3*x[2])^2)*(18 - 32*x[1] + 22 | # 12*x[1]^2 + 48*x[2] - 36*x[1]*x[2] + 27*x[2]^2)) ) 23 | # ∇f(x) = ForwardDiff.gradient(f,x) 24 | 25 | # Beale 26 | # f(x) = ( (1.5 - x[1] + x[1]*x[2])^2 27 | # + (2.25 - x[1] + x[1]*x[2]^2)^2 28 | # + (2.625 - x[1] + x[1]*x[2]^3)^2 ) 29 | # ∇f(x) = ForwardDiff.gradient(f,x) 30 | 31 | 32 | # Rosenbrock 33 | # f(x) = 100*(x[2] - x[1]^2)^2 + (x[1] - 1)^2 34 | # ∇f(x) = ForwardDiff.gradient(f,x) 35 | 36 | # Monkey Saddle 37 | # f(x) = x[1]^3 - 3*x[1]*x[2]^2 38 | # ∇f(x) = [3*x[1] - 3*x[2]^2; -6*x[1]*x[2]] 39 | 40 | A = diagm([1; 1]) 41 | f(x) = 0.5*vecdot(x,A*x) 42 | ∇f(x) = A*x 43 | 44 | α = 1.5; β = 0.51 45 | 46 | w = [1;1]; z = zeros(2) 47 | 48 | N = 2000 49 | fW = zeros(N) 50 | wp = w 51 | W = zeros(2,N) 52 | for i = 1:N 53 | if i > 2 54 | #if vecdot(∇f(w), w - wp) > 0; println(i); z = zeros(2); end 55 | end 56 | W[:,i] = vecdot(∇f(w), w - wp) 57 | wp = w 58 | z = β*z + ∇f(w) 59 | w = w - α*(∇f(w) + β*z) 60 | println(f(w)) 61 | if abs(f(w)) < 100; fW[i] = f(w); else; fW[i] = NaN; end 62 | #W[:,i] = w 63 | end 64 | 65 | plot(fW) -------------------------------------------------------------------------------- /Julia/earlystopping.jl: -------------------------------------------------------------------------------- 1 | #=Copyright (c) 2017 Gabriel Goh 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.=# 19 | 20 | csize = 5; 21 | y = [-1*ones(csize); 1*ones(csize); -1*ones(csize);1*ones(csize);-1*ones(csize);] 22 | y = y + 0.3*cat(1, [[0,1,0,1,0] for i in 1:5]...) 23 | x = cat(1,[collect(c + linspace(-0.03,0.03, csize)) for c in linspace(-1,1,5)]...) 24 | 25 | pdegree = 25 26 | 27 | # Construct Vander* Matrix 28 | A = zeros(length(y),pdegree+1) 29 | for i = 1:size(A,1), j = 1:size(A,2) 30 | A[i,j] = x[i]^(j-1) 31 | end 32 | 33 | Σ,U = eig(A'A) 34 | 35 | p(w,x) = sum([w[i]*x^(i-1) for i = 1:length(w)]) 36 | 37 | Q,R = qr(A) 38 | ws = (R'R)\(A'*y) 39 | plot(r,[p(ws,i) for i in r]) 40 | plot!(ylim = [-2,2]) 41 | scatter!(x,y) 42 | 43 | r = linspace(x[1]-0.1,1+0.1,500) 44 | 45 | w = 100*randn(size(w)) 46 | α = 1/max(eig(A'A)[1]...) 47 | 48 | # for ind = 1:2 49 | # plot!(r,[(U'*ws)[ind]*p(U[:,ind],i) for i in r]) 50 | # end 51 | # plot!(ylim = [0,15]) 52 | # scatter!(x,y) 53 | 54 | @gif for i = 1:100 55 | println(i) 56 | w = getiterk(A'A, A'y, α)(1.4^i) 57 | println(norm(A'*(A*w - y))) 58 | plot(size = (880,180)) 59 | scatter!(x,y) 60 | plot!(r,[p(w,i) for i in r]) 61 | plot!(ylim = [-2,2]) 62 | end 63 | -------------------------------------------------------------------------------- /Julia/iterate.jl: -------------------------------------------------------------------------------- 1 | #=Copyright (c) 2017 Gabriel Goh 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.=# 19 | 20 | A = diagm(Float64[i^2 for i = 1:10]) 21 | x = ones(10) 22 | y = ones(10) 23 | L = min(eig(A)[1]...) 24 | 25 | β = 0.9999 26 | α = 0.000005 27 | X = zeros(10,10000) 28 | fX = zeros(10000) 29 | fx = vecdot(x,A*x) 30 | 31 | for i = 1:10000 32 | xold = x 33 | fxp = fx 34 | fx = 0.5*vecdot(x,A*x) 35 | x = y - α*(A*y) 36 | fxp < fx ? y = x : y = x + β*(x - xold) 37 | X[:,i] = x 38 | fX[i] = 0.5*vecdot(x,A*x) 39 | end 40 | 41 | plot(fX) 42 | 43 | x = ones(10) 44 | y = ones(10) 45 | 46 | for i = 1:10000 47 | xold = x 48 | fxp = fx 49 | fx = 0.5*vecdot(x,A*x) 50 | x = y - α*(A*y) 51 | y = x + β*(x - xold) 52 | X[:,i] = x 53 | fX[i] = 0.5*vecdot(x,A*x) 54 | end 55 | 56 | plot(fX) -------------------------------------------------------------------------------- /Julia/laplacian.jl: -------------------------------------------------------------------------------- 1 | #=Copyright (c) 2017 Gabriel Goh 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.=# 19 | 20 | using Plots 21 | 22 | function getiterk(Q,b,α) 23 | Σ,U = eig(Q) 24 | c = U'b 25 | lambdak(k,λ) = (1 - (1 - α*λ).^k)./λ 26 | return k -> U*(lambdak(k,Σ).*c) 27 | end 28 | 29 | Box = zeros(16,16) 30 | Cavity = ones(16,16) 31 | Cavity[8:9,:] = 0 32 | R = [Box Cavity Box Cavity Box Cavity Box] 33 | A = ones(size(R,1)+2, size(R,2) + 2) 34 | A[2:end-1,2:end-1] = R 35 | 36 | n = size(A,1) - 2 37 | m = size(A,2) - 2 38 | 39 | Ind = zeros(Integer, size(A)) 40 | IndInv = Tuple{Int64,Int64}[] 41 | count = 1 42 | for i = 1:size(A,1), j = 1:size(A,2) 43 | if A[i,j] == 0 44 | Ind[i,j] = count 45 | push!(IndInv, (i,j)) 46 | count = count + 1 47 | end 48 | end 49 | 50 | fp = open("Uval.json","w") 51 | JSON.print(fp, convert(Array{Float16,2},U)) 52 | close(fp) 53 | 54 | fp = open("Sigma.json","w") 55 | JSON.print(fp, Σ) 56 | close(fp) 57 | # ================================================== 58 | # Generate Laplacian 59 | # ================================================== 60 | 61 | Q = zeros(length(IndInv), length(IndInv)) 62 | for i = 2:(size(A,1)-1), j = 2:(size(A,2)-1) 63 | k = Ind[i,j] 64 | if A[i,j] == 0 65 | A[i,j+1] == 0 ? Q[Ind[i,j+1],k] = 1 : nothing 66 | A[i+1,j] == 0 ? Q[Ind[i+1,j],k] = 1 : nothing 67 | A[i,j-1] == 0 ? Q[Ind[i,j-1],k] = 1 : nothing 68 | A[i-1,j] == 0 ? Q[Ind[i-1,j],k] = 1 : nothing 69 | end 70 | end 71 | 72 | Q = (Q + Q')/2 73 | L = diagm(sum(Q,1)[:]) - Q 74 | L[449,449] = L[449,449] + 0.1 75 | L[561,561] = L[561,561] + 0.1 76 | 77 | Σ,U = eig(L) 78 | 79 | function arrange(x) 80 | A = zeros(n,m) 81 | for ind = 1:length(x) 82 | i,j = IndInv[ind] 83 | A[i-1,j-1] = x[ind] 84 | end 85 | return A 86 | end 87 | 88 | plot(size = (880,140)); heatmap!(arrange(U[:,10]), map = "seismic") 89 | 90 | imshow(arrange(U[:,100]), interpolation = "None", cmap = "spectral"); show() 91 | 92 | pyplot(leg=false, ticks=nothing) 93 | 94 | @gif for i in 2:500 95 | plot(size = (880,140)); heatmap!(reshape(U[:,224*3+i],n,m)) 96 | end 97 | 98 | e1 = zeros(length(IndInv)) 99 | e1[449] = 1 100 | e1[561] = 1 101 | 102 | α = 1/max(Σ...) 103 | 104 | iterk = getiterk(L,e1,α) 105 | 106 | imshow(arrange(iterk(10000))) 107 | show() 108 | 109 | # α = 1/max(eig(L)[1]...) 110 | # iters = 5000 111 | # X = zeros(n*m,iters) 112 | # x = 10*zeros(n*m) 113 | # for i = 1:iters 114 | # X[:,i] = x 115 | # for i = 1:100 116 | # x = x - (1*α)*(L*x - e1) 117 | # end 118 | # println(norm(L*x - e1)) 119 | # end 120 | 121 | # plot(size = (880,140)); heatmap!(reshape(X[:,100],n,m)) 122 | # pyplot(leg=false, ticks=nothing) 123 | 124 | # @gif for i in 10:10:2000 125 | # println(i) 126 | # xi = reshape(X[:,i],n,m) 127 | # plot(size = (880,140)); heatmap!(xi) 128 | # end 129 | 130 | # lambdak(k,λ) = α*(1 - (1 - α*λ).^k)./(α*λ) 131 | # c = U'e1 132 | 133 | # @gif for i i guein 10:500:300000 134 | # println(i) 135 | # z = U*(lambdak(i,Σ).*(c) 136 | # plot(size = (880,140)); heatmap!(reshape(z, n, m)) 137 | # end 138 | 139 | # A = randn(10,10); A = A*A' 140 | 141 | # b = rand(10) 142 | # x = zeros(10) 143 | # for i = 1:1000 144 | # x = x - 0.01*(A*x - b) 145 | # end 146 | # x - getiterk(A,b,0.01)(1000) 147 | 148 | -------------------------------------------------------------------------------- /Julia/momentum.jl: -------------------------------------------------------------------------------- 1 | #=Copyright (c) 2017 Gabriel Goh 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.=# 19 | 20 | λ = 1 21 | #M(α,β) = [β λ; -α*β (1-α)] 22 | M(α,β) = [β λ; -α*(β^2) 1-α*λ*(1+β)] 23 | #M(α,β) = [1 αλ; -β-1 -α*β*λ] 24 | S(α,β) = max(abs((eig(M(α,β))[1]))...) 25 | 26 | n = 200 27 | R1 = linspace(0,2,n); 28 | R2 = linspace(-1,1,2*n); 29 | Z = [S(R1[i],R2[j]) for i = 1:n, j = 1:2*n] 30 | 31 | figure(); contour(R1, R2, Z', linspace(0,1,30), cmap = "magma") 32 | contour(R1, R2, Z', [1.,]) 33 | 34 | # figure(); imshow(flipdim(Z',1), cmap = "magma") 35 | 36 | 37 | xlabel(L"\alpha\lambda_i") 38 | ylabel(L"\beta") 39 | 40 | figure(); plot(R2, Z[6,:]',"k") 41 | xlabel(L"\beta") 42 | ylabel("Convergence Rate") -------------------------------------------------------------------------------- /Julia/momentum2.jl: -------------------------------------------------------------------------------- 1 | #=Copyright (c) 2017 Gabriel Goh 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.=# 19 | 20 | srand(1) 21 | 22 | n = 2 23 | U = [1 -1;1 1]/sqrt(2); L = [1 0; 0 2]; 24 | A = U*L*inv(U) 25 | b = -ones(n) 26 | 27 | β = 0.4 28 | α = 1/max(eig(A)[1]...) 29 | 30 | function runmomentum(A,b,k) 31 | z = zeros(length(b)) 32 | w = zeros(length(b)) 33 | for i = 1:k 34 | z = β*z + (A*w - b) 35 | w = w - α*z 36 | end 37 | return (z,w) 38 | end 39 | 40 | function geosumgen(R) 41 | Λ, U = eig(R) 42 | (b,k) -> begin; 43 | Λsum = (1./(1 - Λ)).*(1 - Λ.^k); 44 | real(U*(Λsum.*(U\b))); 45 | end 46 | end 47 | 48 | function runmomentumcheat(A,b,k) 49 | Λ, U = eig(A) 50 | Rmat(i) = [ β Λ[i] ; 51 | -α*β (1- α*Λ[i]) ] 52 | S = inv([ 1 0 ; 53 | α 1 ]) 54 | c = -U'b 55 | fcoll = [geosumgen(Rmat(i)) for i = 1:length(b)] 56 | iters = [fcoll[i](S*[c[i];0],k) for i = 1:length(b)] 57 | catiter = cat(2,iters...) 58 | return (U*catiter[1,:], U*catiter[2,:]) 59 | end 60 | 61 | (a1,b1) = runmomentum(A,b,4) 62 | (a2,b2) = runmomentumcheat(A,b,4) 63 | 64 | norm(a1) -------------------------------------------------------------------------------- /Julia/noisy_gradients.jl: -------------------------------------------------------------------------------- 1 | #=Copyright (c) 2017 Gabriel Goh 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.=# 19 | 20 | 21 | λ = 1 22 | Rf(β, α) = [ β λ; 23 | -α*β (1 - α*λ)] 24 | 25 | α = 0.05 26 | β = 0.4 27 | 28 | ϵ = 8 29 | S = inv([ 1 0 ; 30 | α 1 ]) 31 | 32 | function err(k) 33 | R = Rf(β, α) 34 | sum( ( ((R^(k-i))*([ϵ; -α*ϵ]) )[2] )^2 for i = 1:k ) 35 | end 36 | 37 | function err2(k, α, β) 38 | R = Rf(β, α) 39 | x = [ϵ; -α*ϵ] 40 | s = 0 41 | z = [] 42 | for i = 1:k 43 | s = s + x[2]^2 44 | x = R*x 45 | push!(z, s) 46 | end 47 | return z 48 | end 49 | 50 | err2(100)[50] - err(50) 51 | 52 | function geosumgen(R) 53 | Λ, U = eig(R) 54 | (b,k) -> begin; 55 | Λsum = (1./(1 - Λ)).*(1 - Λ.^k); 56 | real(U*(Λsum.*(U\b))); 57 | end 58 | end 59 | 60 | function runmomentum(A,b,k, ϵ) 61 | z = zeros(length(b)) 62 | w = 3*ones(length(b)) 63 | for i = 1:k 64 | z = β*z + (A*w - b) + ϵ*randn(1) 65 | w = w - α*z 66 | end 67 | return (z[1],w[1]) 68 | end 69 | 70 | function runmomentum2(A,b,k, ϵ) 71 | z = zeros(length(b)) 72 | w = 3*ones(length(b)) 73 | fx = [] 74 | for i = 1:k 75 | z = β*z + (A*w - b) + ϵ*randn(1) 76 | w = w - α*z 77 | push!(fx, w[1]*w[1]) 78 | end 79 | return fx 80 | end 81 | 82 | k = 150 83 | d = mean([runmomentum2(1,0, k, ϵ) for i = 1:100]) 84 | e = err2(k) 85 | d2 = [runmomentum(1,0, i, 0.)[2]^2 for i = 1:k] 86 | 87 | plot(d,".") 88 | plot(d2+e) 89 | #plot(d2) 90 | 91 | plot(err2(200, 0.01, 0)) 92 | -------------------------------------------------------------------------------- /Julia/pde.jl: -------------------------------------------------------------------------------- 1 | #=Copyright (c) 2017 Gabriel Goh 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.=# 19 | 20 | using Plots 21 | 22 | # A = ones(18,67) 23 | 24 | # A[2:end-1,2:end-1] = 0 25 | # A[1:7,32-5:34+5] = 1 26 | # A[end-7:end,32-5:34+5] = 1 27 | 28 | Box = zeros(16,16) 29 | Cavity = ones(16,16) 30 | Cavity[8:9,:] = 0 31 | R = [Box Cavity Box Cavity Box Cavity Box] 32 | A = ones(size(R,1)+2, size(R,2) + 2) 33 | A[2:end-1,2:end-1] = R 34 | 35 | n = size(A,1) - 2 36 | m = size(A,2) - 2 37 | 38 | R = reshape(1:n*m, n,m) 39 | Id(i,j) = R[i-1,j-1] 40 | 41 | Q = zeros(n*m,n*m) 42 | for i = 2:(size(A,1)-1), j = 2:(size(A,2)-1) 43 | k = Id(i,j) 44 | if A[i,j] == 0 45 | A[i,j+1] == 0 ? Q[Id(i,j+1),k] = 1 : nothing 46 | A[i+1,j] == 0 ? Q[Id(i+1,j),k] = 1 : nothing 47 | A[i,j-1] == 0 ? Q[Id(i,j-1),k] = 1 : nothing 48 | A[i-1,j] == 0 ? Q[Id(i-1,j),k] = 1 : nothing 49 | end 50 | end 51 | 52 | Q = (Q + Q')/2 53 | 54 | v = sum(Q,1)[:] 55 | v[v .== 0] = 1 56 | L = diagm(v) - Q 57 | L[1,1] = 2.1 58 | 59 | Σ,U = eig(L) 60 | 61 | pyplot(leg=false, ticks=nothing) 62 | @gif for i in 2:500 63 | plot(size = (880,140)); heatmap!(reshape(U[:,224*3+i],n,m)) 64 | end 65 | 66 | e1 = zeros(n*m) 67 | e1[8:9] = 1 68 | 69 | α = 1/max(eig(L)[1]...) 70 | iters = 5000 71 | X = zeros(n*m,iters) 72 | x = 10*zeros(n*m) 73 | for i = 1:iters 74 | X[:,i] = x 75 | for i = 1:100 76 | x = x - (1*α)*(L*x - e1) 77 | end 78 | println(norm(L*x - e1)) 79 | end 80 | 81 | plot(size = (880,140)); heatmap!(reshape(X[:,100],n,m)) 82 | pyplot(leg=false, ticks=nothing) 83 | 84 | @gif for i in 10:10:2000 85 | println(i) 86 | xi = reshape(X[:,i],n,m) 87 | plot(size = (880,140)); heatmap!(xi) 88 | end 89 | 90 | 91 | lambdak(k,λ) = α*(1 - (1 - α*λ).^k)./(α*λ) 92 | c = U'e1 93 | 94 | 95 | @gif for i in 10:500:300000 96 | println(i) 97 | z = U*(lambdak(i,Σ).*(c) 98 | plot(size = (880,140)); heatmap!(reshape(z, n, m)) 99 | end 100 | 101 | function getiterk(Q,b) 102 | Σ,U = eig(Q) 103 | c = U'b 104 | lambdak(k,λ) = α*(1 - (1 - α*λ).^k)./(α*λ) 105 | return U*(lambdak(k,Σ).*c) 106 | end 107 | 108 | 109 | -------------------------------------------------------------------------------- /Julia/poly2d.jl: -------------------------------------------------------------------------------- 1 | #=Copyright (c) 2017 Gabriel Goh 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.=# 19 | 20 | gen_rand2(n,x) = [(0.1*randn(n,1) + x[1]) (0.1*randn(n,1) - x[2])] 21 | 22 | X = [gen_rand2(12, [1,0.7]); 23 | gen_rand2(12, [-1,0.7]); 24 | gen_rand2(12, [0,-1])]; 25 | 26 | scatter(X[:,1], X[:,2]) 27 | 28 | function Φ(x) 29 | o = Float64[] 30 | for i = 0:5, j = 0:5 31 | push!(o, (x[1]^i)*x[2]^j ) 32 | end 33 | return o 34 | end 35 | 36 | res = 500 37 | Z = [Φ([i,j])[10] for i = linspace(-1,1,res), j = linspace(-1,1,res)] 38 | 39 | D = cat(2,[Φ(X[i,:]) for i = 1:size(X,1)]...) 40 | S,U = eig(D*D') 41 | 42 | n = 3 43 | Z = [vecdot(Φ([i,j]),U[:,n]) for i = linspace(-2,2,res), j = linspace(-2,2,res)] 44 | c = 0.1*sqrt(S[n]) 45 | #heatmap(linspace(-2,2,res),linspace(-2,2,res),min(max(Z,-c),c)) 46 | heatmap(linspace(-2,2,res),linspace(-2,2,res),log(abs(Z))) 47 | scatter!(X[:,2], X[:,1]) -------------------------------------------------------------------------------- /Julia/tem.jl: -------------------------------------------------------------------------------- 1 | #=Copyright (c) 2017 Gabriel Goh 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of 4 | this software and associated documentation files (the "Software"), to deal in 5 | the Software without restriction, including without limitation the rights to 6 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 7 | the Software, and to permit persons to whom the Software is furnished to do so, 8 | subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 15 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 16 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 17 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 18 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.=# 19 | 20 | using ConicIP 21 | 22 | set_default_solver(ConicIPSolver(optTol = 1e-10)) 23 | 24 | b = 0.5*ones(10) 25 | 26 | function Ψ(λ) 27 | x = Variable(15) 28 | p = minimize( 0.5*sumsquares(A*x - b) + λ*norm(y,1) ) 29 | solve!(p) 30 | s = y.value 31 | s[abs(s) .< 1e-8] = 0 32 | return s 33 | end 34 | 35 | x = 0.5*ones(10) 36 | W = randn(10,15) 37 | I = eye(10) 38 | ϵ = 0.001 39 | 40 | K = !(Ψ(x) .== 0) 41 | ystar = Ψ(x) 42 | inv(W[:,K]'W[:,K])*(W[:,K]'x - sign(ystar[K])) 43 | Ψ(x) 44 | 45 | (Ψ(x + ϵ*I[:,1]) - Ψ(x - ϵ*I[:,1]))/(2ϵ) 46 | 47 | inv(W[:,K]'W[:,K])*(W[:,K]') 48 | 49 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # post--momentum 2 | 3 | run `npm install` to install dependencies. 4 | 5 | run `npm run build` to concat those dependencies into a lib file. 6 | 7 | `npm run serve` will run a server so you can preview the ajax calls. 8 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "scripts": { 3 | "build": "cat node_modules/d3/build/d3.min.js node_modules/numeric/numeric-1.2.6.min.js node_modules/d3-swoopy-drag/swoopy-drag.js node_modules/d3-tip/index.js > public/assets/lib/lib.js", 4 | "serve": "python -m SimpleHTTPServer", 5 | "cache-template": "curl http://distill.pub/template.v1.js > public/assets/lib/template.v1.js" 6 | }, 7 | "dependencies": { 8 | "d3": "^4.7.1", 9 | "d3-swoopy-drag": "^0.0.3", 10 | "d3-tip": "^0.7.1", 11 | "distill-template": "^1.0.1", 12 | "numeric": "^1.2.6" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /public/assets/data/matrix.json: -------------------------------------------------------------------------------- 1 | [[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0],[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,1.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0]] -------------------------------------------------------------------------------- /public/assets/flow.js: -------------------------------------------------------------------------------- 1 | function renderFlowWidget(divin, FlowSigma, M, FlowU) { 2 | 3 | var jetc = d3.scaleLinear().domain([-100,1.5,2,3,4,5,10,60,200,500]).range(colorbrewer.RdYlBu[10]); 4 | 5 | var colorBar = divin.append("div").style("position", "absolute").style("left","490px").style("top", "5px").style("height","45px") 6 | 7 | colorMap( colorBar, 8 | 180, 9 | jetc, 10 | d3.scaleLinear().domain([0,100]).range([0, 180]) ) 11 | 12 | divin.append("figcaption") 13 | .style("position", "absolute") 14 | .style("left", "500px") 15 | .style("width", "300px") 16 | .style("top", "70px") 17 | .html("Each square represents a node, colored by its weight. Edges connect each square to the four neighboring squares.") 18 | 19 | divin.append("figcaption") 20 | .style("position", "absolute") 21 | .style("left", "500px") 22 | .style("width", "100px") 23 | .style("top", "0px") 24 | .attr("class", "figtext") 25 | .html("Weights") 26 | 27 | // sliderGen([320, 130]) 28 | // .ticks([0,2/FlowSigma[1119]]) 29 | // .cRadius(5) 30 | // .startxval(4) 31 | // .shifty(10) 32 | // .change(changeStep)(divin.append("div").style("position","relative").style("left", "100px")) 33 | 34 | var slider = divin.append("div").style("position","relative").style("left", "112px") 35 | /* 36 | Generate coordinates for 2D Laplacian based on input matrix 37 | V[i] = (x,y) coordinate of node in 2D space. 38 | */ 39 | var V = [] 40 | for (var i = 0; i < 16; i++) { for (var j = 0; j < 112; j++) { 41 | if (M[i][j] == 0){ V.push([j,i]) } 42 | }} 43 | 44 | /* Generate b in optimization problem x'Ax - b'x */ 45 | var b = zeros(FlowU[0].length); b[448] = 10; b[560] = 10 46 | var step = 1.9/(FlowSigma[1119]) 47 | //var iter = geniter(FlowU, FlowSigma, b, step) 48 | var Ub = numeric.dot(FlowU, b) 49 | 50 | // We can also run this on momentum. 51 | var iterf = geniterMomentum(FlowU, FlowSigma, b, step, 0.999).iter 52 | var iter = function(k) { return iterf(k)[1] } 53 | 54 | /************************************************************************** 55 | START VISUALIZATION 56 | ***************************************************************************/ 57 | divin.style("position", "relative") 58 | 59 | /* Render the 2D grid of pixels, given a div as input 60 | * (appends an svg inside the div) 61 | * Returns a function which allows you to update it */ 62 | function renderGrid(s, transition) { 63 | 64 | var sampleSVG = s.style("display", "block") 65 | .style("margin-left","auto") 66 | .style("margin-right","auto") 67 | .style("width", "920px") 68 | .append("svg") 69 | .attr("width", 920) 70 | .attr("height", 150) 71 | 72 | /* Render discretization of 2D Laplacian*/ 73 | sampleSVG.selectAll("rect") 74 | .data(V) 75 | .enter().append("rect") 76 | .style("fill", function(d,i) { return "white" }) 77 | .attr("height", 7.7) 78 | .attr("width", 7.7) 79 | .attr("x", function(d, i){return d[0]*8+ 10}) 80 | .attr("y", function(d, i){return d[1]*8 + 10}) 81 | 82 | /* display a function on the laplacian using colormap map*/ 83 | var display = function (x, map) { 84 | if (transition === undefined){ 85 | sampleSVG.selectAll("rect").style("fill", function(d,i) { return map(x[i]) }) 86 | } else { 87 | sampleSVG.transition() 88 | .duration(transition) 89 | .selectAll("rect") 90 | .style("fill", function(d,i) { return map(x[i]) }) 91 | } 92 | } 93 | 94 | return display 95 | 96 | } 97 | 98 | var display = renderGrid(divin) 99 | /* Render Control Slider */ 100 | 101 | // Callbacks 102 | var showEigen = function (d,i) { 103 | display(FlowU[i], divergent) 104 | } 105 | 106 | var cacheval = -1 107 | var cacheiter = null 108 | var onDragSlider = function (i) { 109 | var i = Math.floor(Math.exp(i-1)) 110 | if (cacheval != i) { 111 | cacheiter = iter(i) 112 | cacheval = i 113 | } 114 | display(cacheiter, jetc) 115 | } 116 | 117 | display(iter(100), jetc) // Set it up to a nice looking default 118 | 119 | var barLengths = getStepsConvergence(FlowSigma,step) 120 | .map( function(i) {return Math.abs(Math.log(i+1)) } ).filter( function(d,i) { return (i < 50) || i%20 == 0 } ) 121 | 122 | var slideControl = sliderBarGen(barLengths, function(x) { return Math.exp(x-1)} ) 123 | .height(281) 124 | .linewidth(1.3) 125 | .maxX(13.3) 126 | .mouseover( function(d,i) { display(FlowU[i], divergent) }) 127 | .labelFunc(function (d,i) { 128 | if (i < 50) { 129 | return ((i == 0) ? "Eigenvalue 1" : "") + (( (i+1) % 25 == 0 ) ? (i + 1) : "") 130 | } else { 131 | return (( (i+1) % 25 == 0 ) ? 20*(i + 1) : "") 132 | } 133 | }) 134 | .update(onDragSlider)(divin) 135 | 136 | slideControl.slidera.init() 137 | 138 | function changeStep(alpha, beta) { 139 | var iteration = geniterMomentum(FlowU, FlowSigma, b, Math.max(alpha/FlowSigma[1119],0.00000001), Math.min(beta,0.999999)) 140 | iterf = iteration.iter 141 | var barLengths = getStepsConvergence(iteration.maxLambda.map(function(i) { return 1- i}), 1) 142 | .map( function(i) {return Math.log(Math.max(i,1))} ) 143 | .filter( function(d,i) { return (i < 50) || i%20 == 0 } ) 144 | slideControl.update(barLengths) 145 | iter = function(k) { return iterf(k)[1] } 146 | cacheval = -1 147 | slideControl.slidera.init() 148 | } 149 | var reset = slider2D(slider, changeStep, FlowSigma[0], FlowSigma[1119], [1.9,0.00001]) 150 | 151 | slider.append("div") 152 | .attr("class","figtext") 153 | .style("left", "155px") 154 | .style("top", "0px") 155 | .style("position","absolute") 156 | .style("pointer-events", "none") 157 | .html("Step-size α =") 158 | 159 | slider.append("div") 160 | .attr("class","figtext") 161 | .style("left", "-87px") 162 | .style("top", "20px") 163 | .style("position","absolute") 164 | .style("pointer-events", "none") 165 | .html("Momentum β = ") 166 | 167 | return reset 168 | } 169 | 170 | //
Step-size α =
171 | //
Momentum β =
172 | -------------------------------------------------------------------------------- /public/assets/graph.js: -------------------------------------------------------------------------------- 1 | var seed = 17; 2 | function random() { 3 | var x = Math.sin(seed++) * 10000; 4 | return x - Math.floor(x); 5 | } 6 | 7 | function generateGraph(svg, graph, linklength, strength) { 8 | 9 | var width = 300; 10 | var height = 200; 11 | 12 | var simulation = d3.forceSimulation() 13 | .force("link", d3.forceLink().id(function(d) { return d.id; }) 14 | .strength(2) 15 | .distance(function() {return linklength})) 16 | .force("charge", d3.forceManyBody().strength(-110)) 17 | .force("center", d3.forceCenter(width / 2, height / 2)) 18 | .force("x",d3.forceX(1000).strength(strength)) 19 | .force("y",d3.forceY(1000).strength(strength)) 20 | .stop() 21 | var link = svg.append("g") 22 | .attr("class", "links") 23 | .selectAll("line") 24 | .data(graph.links) 25 | .enter().append("line") 26 | .attr("stroke-width", 1) 27 | .attr("stroke","black") 28 | 29 | var node = svg.append("g") 30 | .attr("class", "nodes") 31 | 32 | 33 | var nodedata = node 34 | .selectAll("circle") 35 | .data(graph.nodes) 36 | .enter().append("circle") 37 | .attr("r", 3) 38 | .attr("fill", "black") 39 | 40 | nodedata.append("title") 41 | .text(function(d) { return d.id; }); 42 | 43 | simulation 44 | .nodes(graph.nodes) 45 | .on("tick", ticked); 46 | 47 | simulation.force("link") 48 | .links(graph.links); 49 | 50 | for (var i = 0; i < 200; ++i) { 51 | simulation.tick(); 52 | } 53 | 54 | function ticked() { 55 | link.attr("x1", function(d) { return d.source.x; }) 56 | .attr("y1", function(d) { return d.source.y; }) 57 | .attr("x2", function(d) { return d.target.x; }) 58 | .attr("y2", function(d) { return d.target.y; }); 59 | 60 | nodedata.attr("cx", function(d) { return d.x; }) 61 | .attr("cy", function(d) { return d.y; }); 62 | } 63 | 64 | var updateColors = function (update) { 65 | node.selectAll("circle") 66 | .data(update) 67 | .attr("fill", function(d,i) { return d}) 68 | } 69 | 70 | ticked() 71 | 72 | return updateColors 73 | }; 74 | 75 | 76 | function genGrid(svg) { 77 | 78 | var data = {"nodes": [],"links": []} 79 | var id = {} 80 | 81 | var n = 6 82 | var c = 0 83 | for (var i = 0; i < n; i ++) { 84 | for (var j = 0; j < n; j ++) { 85 | data.nodes.push({"id": i + "," + j}) 86 | id[i + "," + j] = c 87 | c++ 88 | } 89 | } 90 | 91 | var L = zeros2D(c,c) 92 | 93 | for (var i = 0; i < n; i++) { 94 | for (var j = 0; j < n; j++){ 95 | if (j < (n-1)) { 96 | data.links.push({"source":i + "," + j, "target": i + "," + (j + 1)}) 97 | L[id[i + "," + j]][id[i + "," + (j+1)]] = -1 98 | L[id[i + "," + (j+1)]][id[i + "," + j]] = -1 99 | } 100 | if (i < (n-1)) { 101 | data.links.push({"source":i + "," + j, "target": (i + 1) + "," + j}) 102 | L[id[i + "," + j]][id[(i+1) + "," + j]] = -1 103 | L[id[(i+1) + "," + j]][id[i + "," + j]] = -1 104 | } 105 | } 106 | } 107 | 108 | for (var i = 0; i < c; i++) { 109 | L[i][i] = -numeric.sum(L[i]) + ((i == 0) ? 1 : 0) 110 | } 111 | 112 | colorbrewer.Spectral[3] 113 | var divergent = d3.scaleLinear().domain([-0.1,0,0.1]).range(["#fc8d59", "#e6e600", "#99d594"]); 114 | 115 | var E = eigSym(L) 116 | 117 | var update = generateGraph(svg, data,2,0.2) 118 | 119 | var colors = [] 120 | for (var i = 0; i < c; i++) { 121 | colors.push(divergent(E.U[34][i])) 122 | } 123 | update(colors) 124 | 125 | 126 | } 127 | 128 | 129 | function genPath(svg) { 130 | var data = {"nodes": [], "links": []} 131 | 132 | var n = 36 133 | var L = zeros2D(n,n) 134 | for (var i = 0; i < n; i ++) { 135 | data.nodes.push({"id": i}) 136 | if (i < (n-1)){ 137 | data.links.push({"source":i, "target": i+1}) 138 | L[i][i+1] = -1 139 | L[i+1][i] = -1 140 | } 141 | } 142 | 143 | for (var i = 0; i < 3; i++){ 144 | var s = Math.floor(random()*36) 145 | var t = Math.floor(random()*36) 146 | data.links.push({"source":s, "target": t}) 147 | L[s][t] = -1 148 | L[t][s] = -1 149 | } 150 | 151 | for (var i = 0; i < n; i++) { 152 | L[i][i] = -numeric.sum(L[i]) + ((i == 0) ? 1 : 0) 153 | } 154 | 155 | var divergent = d3.scaleLinear().domain([-0.1,0,0.1]).range(["#fc8d59", "#e6e600", "#99d594"]); 156 | 157 | var E = eigSym(L) 158 | 159 | var update = generateGraph(svg, data, 3, 0.43) 160 | var colors = [] 161 | for (var i = 0; i < n; i++) { 162 | colors.push(divergent(E.U[34][i])) 163 | } 164 | update(colors) 165 | 166 | 167 | } 168 | 169 | 170 | function genExpander(svg) { 171 | var data = {"nodes": [], "links": []} 172 | var n = 36 173 | var L = zeros2D(n,n) 174 | 175 | for (var i = 0; i < n; i ++) { 176 | data.nodes.push({"id": i}) 177 | } 178 | 179 | for (var i = 0; i < 80; i++){ 180 | var s = Math.floor(random()*36); 181 | var t = Math.floor(random()*36) 182 | data.links.push({"source":s, "target": t}) 183 | L[s][t] = -1 184 | L[t][s] = -1 185 | } 186 | 187 | for (var i = 0; i < n; i++) { 188 | L[i][i] = -numeric.sum(L[i]) + ((i == 0) ? 1 : 0) 189 | } 190 | var divergent = d3.scaleLinear().domain([-0.1,0,0.1]).range(["#fc8d59", "#e6e600", "#99d594"]); 191 | 192 | var E = eigSym(L) 193 | var update = generateGraph(svg, data, 20, 0.2) 194 | var colors = [] 195 | for (var i = 0; i < n; i++) { 196 | colors.push(divergent(E.U[34][i])) 197 | } 198 | update(colors) 199 | } 200 | 201 | -------------------------------------------------------------------------------- /public/assets/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 17 | 18 | 19 |

Hello World

20 |

A description of the article

21 | 22 |

This is the first paragraph of the article.

23 |

We can also cite external publications.

24 |
25 | 26 | -------------------------------------------------------------------------------- /public/assets/iterates.js: -------------------------------------------------------------------------------- 1 | /* 2 | Make a standard "path of descent" plot which shows iterates 3 | on a 2D optimization landscape 4 | 5 | Takes in : f, the objective function 6 | Name of div where the graphic is rendered 7 | update, which gets passed in the objective 8 | values at every iteration 9 | 10 | Returns : callback `changeParams` to change alpha, beta 11 | */ 12 | function genIterDiagram(f, xstar, axis) { 13 | 14 | /* 15 | Configurable Parameters 16 | */ 17 | var w = 984 18 | var h = 300 19 | var totalIters = 150 20 | var state_beta = 0.0 21 | var state_alpha = 0.001 22 | var num_contours = 15 23 | var onDrag = function() {} 24 | var w0 =[-1.21, 0.853] 25 | var strokeColor = "#ff6600" 26 | var showOptimum = true 27 | var showSolution = true 28 | var pathWidth = 1.5 29 | var circleRadius = 2 30 | var pointerScale = 1 31 | var showStartingPoint = true 32 | 33 | function renderIterates(div) { 34 | 35 | // Render the other stuff 36 | var intDiv = div.style("width", w + "px") 37 | .style("height", h + "px") 38 | 39 | // Render Contours 40 | var plotCon = contour_plot.ContourPlot(w,h) 41 | .f(function(x,y) { return f([x,y])[0] }) 42 | .drawAxis(false) 43 | .xDomain(axis[0]) 44 | .yDomain(axis[1]) 45 | .contourCount(num_contours) 46 | .minima([{x:xstar[0], y:xstar[1]}]); 47 | 48 | var elements = plotCon(intDiv); 49 | 50 | var svg = intDiv.append("div") 51 | .append("svg") 52 | .style("position", 'absolute') 53 | .style("left", 0) 54 | .style("top", 0) 55 | .style("width", w + "px") 56 | .style("height", h + "px") 57 | .style("z-index", 2) 58 | 59 | var X = d3.scaleLinear().domain(axis[0]).range([0, w]) 60 | var Y = d3.scaleLinear().domain(axis[1]).range([0, h]) 61 | 62 | // Rendeer Draggable dot 63 | var circ = svg.append("g") //use xlink:href="cafe-18.svg#svg4619"> 64 | .attr("transform", "translate(" + X(w0[0]) + "," + Y(w0[1]) + ")") 65 | .call(d3.drag().on("drag", function() { 66 | var pt = d3.mouse(svg.node()) 67 | var x = X.invert(pt[0]) 68 | var y = Y.invert(pt[1]) 69 | this.setAttribute("transform","translate(" + pt[0] + "," + pt[1] + ")") 70 | w0 = [x,y] 71 | onDrag(w0) 72 | iter(state_alpha, state_beta, w0); 73 | })) 74 | 75 | circ.append("use") 76 | .style("cursor", "pointer") 77 | .attr("xlink:href", "#pointerThingy") 78 | .attr("transform", "scale(" + pointerScale + ")") 79 | 80 | if (showStartingPoint) { 81 | circ.append("text") 82 | .style("cursor", "pointer") 83 | .attr("class", "figtext") 84 | .attr("transform", "translate(20,3)") 85 | .html("Starting Point") 86 | } 87 | 88 | var iterColor = d3.scaleLinear().domain([0, totalIters]).range([strokeColor, strokeColor]) 89 | 90 | var update2D = plot2dGen(X, Y, iterColor) 91 | .stroke(strokeColor) 92 | .pathWidth(pathWidth) 93 | .circleRadius(circleRadius)(svg) 94 | 95 | 96 | if (showOptimum) { 97 | // Append x^s var showSolution = falsetar 98 | var pxstar = ringPathGen(7,50,14)([X(xstar[0]), Y(xstar[1])], 99 | [X(xstar[0]), Y(xstar[1]) - 15]) 100 | svg.append("circle").attr("cx", X(xstar[0])).attr("cy", Y(xstar[1])).attr("r", 7).attr("stroke","#3f5b75").attr("stroke-width",1).attr("fill","none") 101 | svg.append("path").attr("d", pxstar.d).attr("stroke","#3f5b75").attr("stroke-width",1).attr("fill","none") 102 | svg.append("text") 103 | .attr("class","figtext") 104 | .attr("transform", "translate(" + pxstar.label[0] + "," + (pxstar.label[1]) + ")" ) 105 | .html("Optimum") 106 | } 107 | 108 | 109 | if (showSolution) { 110 | var pxsol = ringPathGen(7,43.36,14)([X(0), Y(0)], 111 | [X(0), Y(0) + 20]) 112 | var solcirc = svg.append("circle").attr("cx", X(0)).attr("cy", Y(0)).attr("r", 7).attr("stroke",strokeColor).attr("stroke-width",1).attr("fill","none") 113 | var solpath = svg.append("path").attr("d", pxsol.d).attr("stroke",strokeColor).attr("stroke-width",1).attr("fill","none") 114 | var sollabel = svg.append("text") 115 | .attr("class","figtext") 116 | .attr("transform", "translate(" + pxsol.label[0] + "," + (pxsol.label[1]) + ")" ) 117 | .html("Solution") 118 | } 119 | function updateSol(x,y) { 120 | if (showSolution) { 121 | var pxsol = ringPathGen(7,50,14)([X(x), Y(y)], [X(x), Y(y) + 15]) 122 | solcirc.attr("cx", X(x)).attr("cy", Y(y)) 123 | solpath.attr("d", pxsol.d) 124 | sollabel.attr("transform", "translate(" + pxsol.label[0] + "," + (pxsol.label[1]) + ")" ) 125 | } 126 | } 127 | 128 | // svg.append("rect") 129 | // .attr("width", 50) 130 | // .attr("height",14) 131 | // .attr("x", pxstar.label[0] ) 132 | // .attr("y", pxstar.label[1]) 133 | 134 | function iter(alpha, beta, w0) { 135 | 136 | // Update Internal state of alpha and beta 137 | state_alpha = alpha 138 | state_beta = beta 139 | 140 | // Generate iterates 141 | var OW = runMomentum(f, w0, alpha, beta, totalIters) 142 | var W = OW[1] 143 | 144 | update2D(W) 145 | updateSol(OW[1][150][0], OW[1][150][1]) 146 | circ.attr("transform", "translate(" + X(w0[0]) + "," + Y(w0[1]) + ")" ) 147 | circ.moveToFront() 148 | 149 | } 150 | 151 | iter(state_alpha, state_beta, w0); 152 | 153 | return { control:iter, 154 | w0:function() { return w0 }, 155 | alpha:function() { return state_alpha }, 156 | beta:function() {return state_beta} } 157 | 158 | } 159 | 160 | renderIterates.showStartingPoint = function(_) { 161 | showStartingPoint = _; return renderIterates; 162 | } 163 | 164 | renderIterates.pointerScale = function(_) { 165 | pointerScale = _; return renderIterates; 166 | } 167 | 168 | renderIterates.circleRadius = function(_) { 169 | circleRadius = _; return renderIterates; 170 | } 171 | 172 | renderIterates.pathWidth = function(_) { 173 | pathWidth = _; return renderIterates; 174 | } 175 | 176 | renderIterates.showSolution = function(_) { 177 | showSolution = _; return renderIterates; 178 | } 179 | 180 | renderIterates.showOptimum = function(_) { 181 | showOptimum = _; return renderIterates; 182 | } 183 | 184 | renderIterates.strokeColor = function(_) { 185 | strokeColor = _; return renderIterates; 186 | } 187 | 188 | renderIterates.width = function (_) { 189 | w = _; return renderIterates; 190 | } 191 | 192 | renderIterates.height = function (_) { 193 | h = _; return renderIterates; 194 | } 195 | 196 | renderIterates.iters = function (_) { 197 | totalIters = _; return renderIterates; 198 | } 199 | 200 | renderIterates.drag = function (_) { 201 | onDrag = _; return renderIterates; 202 | } 203 | 204 | renderIterates.init = function (_) { 205 | w0 = _; return renderIterates; 206 | } 207 | 208 | renderIterates.alpha = function (_) { 209 | state_alpha = _; return renderIterates; 210 | } 211 | 212 | renderIterates.beta = function (_) { 213 | state_beta = _; return renderIterates; 214 | } 215 | 216 | return renderIterates 217 | 218 | } 219 | -------------------------------------------------------------------------------- /public/assets/lib/auto-render.min.js: -------------------------------------------------------------------------------- 1 | (function(e){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=e()}else if(typeof define==="function"&&define.amd){define([],e)}else{var t;if(typeof window!=="undefined"){t=window}else if(typeof global!=="undefined"){t=global}else if(typeof self!=="undefined"){t=self}else{t=this}t.renderMathInElement=e()}})(function(){var e,t,r;return function n(e,t,r){function a(o,l){if(!t[o]){if(!e[o]){var f=typeof require=="function"&&require;if(!l&&f)return f(o,!0);if(i)return i(o,!0);var d=new Error("Cannot find module '"+o+"'");throw d.code="MODULE_NOT_FOUND",d}var s=t[o]={exports:{}};e[o][0].call(s.exports,function(t){var r=e[o][1][t];return a(r?r:t)},s,s.exports,n,e,t,r)}return t[o].exports}var i=typeof require=="function"&&require;for(var o=0;o px) { 88 | // East 89 | if (y > py) return "SE"; 90 | if (y < -py) return "NE"; 91 | if (x > r) return "E"; 92 | return null; 93 | } 94 | else if (x < -px) { 95 | // West 96 | if (y > py) return "SW"; 97 | if (y < -py) return "NW"; 98 | if (x < -r) return "W"; 99 | return null; 100 | } 101 | else { 102 | // Center 103 | if (y > r) return "S"; 104 | if (y < -r) return "N"; 105 | } 106 | } 107 | } 108 | 109 | function dragmoveCenter(d) { 110 | var gRingNote = d3.select(this.parentNode.parentNode); 111 | 112 | d.cx += d3.event.x; 113 | d.cy += d3.event.y; 114 | 115 | gRingNote 116 | .attr("transform", function(d) { 117 | return "translate(" + d.cx + "," + d.cy + ")"; 118 | }); 119 | } 120 | 121 | function dragmoveRadius(d) { 122 | var gRingNote = d3.select(this.parentNode.parentNode), 123 | gAnnotation = gRingNote.select(".annotation"), 124 | circle = gAnnotation.select("circle"), 125 | line = gAnnotation.select("path"), 126 | text = gAnnotation.select("text"), 127 | radius = d3.select(this); 128 | 129 | d.r += d3.event.dx; 130 | 131 | circle.attr("r", function(d) { return d.r; }); 132 | radius.attr("cx", function(d) { return d.r; }); 133 | line.call(updateLine); 134 | text.call(updateText); 135 | } 136 | 137 | function dragmoveText(d) { 138 | var gAnnotation = d3.select(this.parentNode), 139 | line = gAnnotation.select("path"), 140 | text = d3.select(this); 141 | 142 | d.textOffset[0] += d3.event.dx; 143 | d.textOffset[1] += d3.event.dy; 144 | 145 | text.call(updateText); 146 | line.call(updateLine); 147 | } 148 | 149 | function updateLine(selection) { 150 | return selection.attr("d", function(d) { 151 | var x = d.textOffset[0], 152 | y = d.textOffset[1], 153 | lineData = getLineData(x, y, d.r); 154 | return path(lineData); 155 | }); 156 | } 157 | 158 | function getLineData(x, y, r) { 159 | var region = getRegion(x, y, r); 160 | 161 | if (region == null) { 162 | // No line if text is inside the circle 163 | return []; 164 | } 165 | else { 166 | // Cardinal directions 167 | if (region == "N") return [[0, -r], [0, y]]; 168 | if (region == "E") return [[r, 0], [x, 0]]; 169 | if (region == "S") return [[0, r], [0, y]]; 170 | if (region == "W") return [[-r, 0],[x, 0]]; 171 | 172 | var d0 = r * Math.cos(Math.PI/4), 173 | d1 = Math.min(Math.abs(x), Math.abs(y)) - d0; 174 | 175 | // Intermediate directions 176 | if (region == "NE") return [[ d0, -d0], [ d0 + d1, -d0 - d1], [x, y]]; 177 | if (region == "SE") return [[ d0, d0], [ d0 + d1, d0 + d1], [x, y]]; 178 | if (region == "SW") return [[-d0, d0], [-d0 - d1, d0 + d1], [x, y]]; 179 | if (region == "NW") return [[-d0, -d0], [-d0 - d1, -d0 - d1], [x, y]]; 180 | } 181 | } 182 | 183 | function updateText(selection) { 184 | return selection.each(function(d) { 185 | var x = d.textOffset[0], 186 | y = d.textOffset[1], 187 | region = getRegion(x, y, d.r), 188 | textCoords = getTextCoords(x, y, region); 189 | 190 | d3.select(this) 191 | .attr("x", textCoords.x) 192 | .attr("y", textCoords.y) 193 | .text(d.text) 194 | .each(function(d) { 195 | var x = d.textOffset[0], 196 | y = d.textOffset[1], 197 | textAnchor = getTextAnchor(x, y, region); 198 | 199 | var dx = textAnchor == "start" ? "0.33em" : 200 | textAnchor == "end" ? "-0.33em" : "0"; 201 | 202 | var dy = textAnchor !== "middle" ? ".33em" : 203 | ["NW", "N", "NE"].indexOf(region) !== -1 ? "-.33em" : "1em"; 204 | 205 | var orientation = textAnchor !== "middle" ? undefined : 206 | ["NW", "N", "NE"].indexOf(region) !== -1 ? "bottom" : "top"; 207 | 208 | d3.select(this) 209 | .style("text-anchor", textAnchor) 210 | .attr("dx", dx) 211 | .attr("dy", dy) 212 | .call(wrapText, d.textWidth || 960, orientation); 213 | }); 214 | }); 215 | } 216 | 217 | function getTextCoords(x, y, region) { 218 | if (region == "N") return { x: 0, y: y }; 219 | if (region == "E") return { x: x, y: 0 }; 220 | if (region == "S") return { x: 0, y: y }; 221 | if (region == "W") return { x: x, y: 0 }; 222 | return { x: x, y: y }; 223 | } 224 | 225 | function getTextAnchor(x, y, region) { 226 | if (region == null) { 227 | return "middle"; 228 | } 229 | else { 230 | // Cardinal directions 231 | if (region == "N") return "middle"; 232 | if (region == "E") return "start"; 233 | if (region == "S") return "middle"; 234 | if (region == "W") return "end"; 235 | 236 | var xLonger = Math.abs(x) > Math.abs(y); 237 | 238 | // Intermediate directions` 239 | if (region == "NE") return xLonger ? "start" : "middle"; 240 | if (region == "SE") return xLonger ? "start" : "middle"; 241 | if (region == "SW") return xLonger ? "end" : "middle"; 242 | if (region == "NW") return xLonger ? "end" : "middle"; 243 | } 244 | } 245 | 246 | // Adapted from: https://bl.ocks.org/mbostock/7555321 247 | function wrapText(text, width, orientation) { 248 | text.each(function(d) { 249 | var text = d3.select(this), 250 | words = text.text().split(/\s+/).reverse(), 251 | word, 252 | line = [], 253 | lineNumber = 1, 254 | lineHeight = 1.1, // ems 255 | x = text.attr("x"), 256 | dx = text.attr("dx"), 257 | tspan = text.text(null).append("tspan").attr("x", x).attr("dx", dx); 258 | while (word = words.pop()) { 259 | line.push(word); 260 | tspan.text(line.join(" ")); 261 | if (tspan.node().getComputedTextLength() > width) { 262 | line.pop(); 263 | tspan.text(line.join(" ")); 264 | line = [word]; 265 | tspan = text.append("tspan") 266 | .attr("x", x) 267 | .attr("dx", dx) 268 | .attr("dy", lineHeight + "em") 269 | .text(word); 270 | lineNumber++; 271 | } 272 | } 273 | 274 | var dy; 275 | if (orientation == "bottom") { 276 | dy = -lineHeight * (lineNumber-1) - .33; 277 | } 278 | else if (orientation == "top") { 279 | dy = 1; 280 | } 281 | else { 282 | dy = -lineHeight * ((lineNumber-1) / 2) + .33; 283 | } 284 | text.attr("dy", dy + "em"); 285 | 286 | }); 287 | } 288 | 289 | function styleControl(selection) { 290 | selection 291 | .attr("r", controlRadius) 292 | .style("fill-opacity", "0") 293 | .style("stroke", "black") 294 | .style("stroke-dasharray", "3, 3") 295 | .style("cursor", "move"); 296 | } 297 | 298 | return draw; 299 | }; -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_AMS-Regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_AMS-Regular.eot -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_AMS-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_AMS-Regular.ttf -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_AMS-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_AMS-Regular.woff -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_AMS-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_AMS-Regular.woff2 -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Caligraphic-Bold.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Caligraphic-Bold.eot -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Caligraphic-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Caligraphic-Bold.ttf -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Caligraphic-Bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Caligraphic-Bold.woff -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Caligraphic-Bold.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Caligraphic-Bold.woff2 -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Caligraphic-Regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Caligraphic-Regular.eot -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Caligraphic-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Caligraphic-Regular.ttf -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Caligraphic-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Caligraphic-Regular.woff -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Caligraphic-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Caligraphic-Regular.woff2 -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Fraktur-Bold.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Fraktur-Bold.eot -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Fraktur-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Fraktur-Bold.ttf -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Fraktur-Bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Fraktur-Bold.woff -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Fraktur-Bold.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Fraktur-Bold.woff2 -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Fraktur-Regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Fraktur-Regular.eot -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Fraktur-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Fraktur-Regular.ttf -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Fraktur-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Fraktur-Regular.woff -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Fraktur-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Fraktur-Regular.woff2 -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Main-Bold.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Main-Bold.eot -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Main-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Main-Bold.ttf -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Main-Bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Main-Bold.woff -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Main-Bold.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Main-Bold.woff2 -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Main-Italic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Main-Italic.eot -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Main-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Main-Italic.ttf -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Main-Italic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Main-Italic.woff -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Main-Italic.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Main-Italic.woff2 -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Main-Regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Main-Regular.eot -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Main-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Main-Regular.ttf -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Main-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Main-Regular.woff -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Main-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Main-Regular.woff2 -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Math-BoldItalic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Math-BoldItalic.eot -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Math-BoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Math-BoldItalic.ttf -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Math-BoldItalic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Math-BoldItalic.woff -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Math-BoldItalic.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Math-BoldItalic.woff2 -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Math-Italic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Math-Italic.eot -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Math-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Math-Italic.ttf -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Math-Italic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Math-Italic.woff -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Math-Italic.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Math-Italic.woff2 -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Math-Regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Math-Regular.eot -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Math-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Math-Regular.ttf -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Math-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Math-Regular.woff -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Math-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Math-Regular.woff2 -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_SansSerif-Bold.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_SansSerif-Bold.eot -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_SansSerif-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_SansSerif-Bold.ttf -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_SansSerif-Bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_SansSerif-Bold.woff -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_SansSerif-Bold.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_SansSerif-Bold.woff2 -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_SansSerif-Italic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_SansSerif-Italic.eot -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_SansSerif-Italic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_SansSerif-Italic.ttf -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_SansSerif-Italic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_SansSerif-Italic.woff -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_SansSerif-Italic.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_SansSerif-Italic.woff2 -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_SansSerif-Regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_SansSerif-Regular.eot -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_SansSerif-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_SansSerif-Regular.ttf -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_SansSerif-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_SansSerif-Regular.woff -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_SansSerif-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_SansSerif-Regular.woff2 -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Script-Regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Script-Regular.eot -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Script-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Script-Regular.ttf -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Script-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Script-Regular.woff -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Script-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Script-Regular.woff2 -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Size1-Regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Size1-Regular.eot -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Size1-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Size1-Regular.ttf -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Size1-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Size1-Regular.woff -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Size1-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Size1-Regular.woff2 -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Size2-Regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Size2-Regular.eot -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Size2-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Size2-Regular.ttf -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Size2-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Size2-Regular.woff -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Size2-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Size2-Regular.woff2 -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Size3-Regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Size3-Regular.eot -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Size3-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Size3-Regular.ttf -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Size3-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Size3-Regular.woff -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Size3-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Size3-Regular.woff2 -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Size4-Regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Size4-Regular.eot -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Size4-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Size4-Regular.ttf -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Size4-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Size4-Regular.woff -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Size4-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Size4-Regular.woff2 -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Typewriter-Regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Typewriter-Regular.eot -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Typewriter-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Typewriter-Regular.ttf -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Typewriter-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Typewriter-Regular.woff -------------------------------------------------------------------------------- /public/assets/lib/fonts/KaTeX_Typewriter-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/assets/lib/fonts/KaTeX_Typewriter-Regular.woff2 -------------------------------------------------------------------------------- /public/assets/milestones.js: -------------------------------------------------------------------------------- 1 | function renderMilestones(div, updateTick) { 2 | var lambda = [1,10,100] 3 | var totalIters = 151 4 | 5 | div.append("defs").append("marker") 6 | .attr("id", "arrowhead") 7 | .attr("refX", 3) 8 | .attr("refY", 2) 9 | .attr("markerWidth", 4) 10 | .attr("markerHeight", 4) 11 | .attr("orient", "auto") 12 | .append("path") 13 | .attr("d", "M 0,0 V 4 L4,2 Z"); //this is actual shape for arrowhead 14 | 15 | var markers = [] 16 | for (var i = 0; i < 3; i ++) { 17 | var marker = div.append("defs").append("marker") 18 | .attr("id", "arrowhead" + i) 19 | .attr("refX", 0) 20 | .attr("refY", 1) 21 | .attr("markerWidth", 4) 22 | .attr("markerHeight", 4) 23 | .attr("orient", "auto") 24 | .append("path") 25 | .attr("d", "M 0,0 V 2 L2,1 Z") //this is actual shape for arrowhead 26 | .attr("fill", colorbrewer.RdPu[3][i]) 27 | markers.push(marker) 28 | } 29 | 30 | var f = function(x) { 31 | var fx = 0.5*(lambda[0]*x[0]*x[0] + lambda[1]*x[1]*x[1] + lambda[2]*x[2]*x[2]) 32 | var g = [lambda[0]*x[0], lambda[1]*x[1], lambda[2]*x[2]] 33 | return [fx, g] 34 | } 35 | 36 | /* 37 | Gets information about iterates with certain parameter alpha and beta. 38 | > v = getTrace(0.5, 0) 39 | v[0] -> z iterates 40 | v[1] -> w iterates 41 | v[2] -> [c1, c2, c3] where c1, c2, c3 are the contributions to the loss 42 | */ 43 | function getTrace(alpha, beta) { 44 | var w0 = [1,1/Math.sqrt(lambda[1]),1/Math.sqrt(lambda[2])] 45 | var v = runMomentum(f, w0, alpha, beta, totalIters) 46 | var fxstack = [] 47 | // Add contributions to the objective 48 | for (var i = 0; i < v[0].length; i++) { 49 | var x = v[1][i] 50 | fxstack.push([lambda[0]*x[0]*x[0]/2, lambda[1]*x[1]*x[1]/2, lambda[2]*x[2]*x[2]/2 ]) 51 | } 52 | v.push(fxstack) 53 | return v 54 | } 55 | 56 | var stackedBar = stackedBarchartGen(totalIters, 3)(div) 57 | 58 | var seperation = 14 59 | 60 | var r = [] 61 | var lines = [] 62 | 63 | var progressmeter = div.append("g") 64 | for (var i = 0; i < 3; i ++) { 65 | var ri = progressmeter.append("line") 66 | .attr("x1", stackedBar.X(-1) + "px") 67 | .attr("y1", (202 + i*seperation)+ "px") 68 | .attr("stroke", colorbrewer.RdPu[3][i]) 69 | .attr("y2", (202 + i*seperation) + "px") 70 | .attr("stroke-width", 4) 71 | r.push(ri) 72 | 73 | var linei = progressmeter.append("line") 74 | .style("stroke", "black") 75 | .style("stroke-width",1.5) 76 | .attr("marker-end", "url(#arrowhead)") 77 | .attr("opacity", 0.6) 78 | lines.push(linei) 79 | 80 | progressmeter.append("text") 81 | .attr("class", "figtext2") 82 | .attr("x", 0) 83 | .attr("y", 206 + i*seperation) 84 | .attr("text-anchor", "end") 85 | .attr("fill", "gray") 86 | .html((i == 0) ? "Eigenvalue " + (i+1) : (i+1) ) 87 | } 88 | 89 | 90 | var updateStep = function(alpha, beta) { 91 | var trace = getTrace(alpha/lambda[2], beta) 92 | // Update the milestones on the slider 93 | var milestones = [0,0,0] 94 | for (var i = 0; i < trace[1].length; i++) { 95 | if (trace[2][i][0] > 0.01) { milestones[2] = i } 96 | if (trace[2][i][1] > 0.01) { milestones[1] = i } 97 | if (trace[2][i][2] > 0.01) { milestones[0] = i } 98 | } 99 | stackedBar.update(trace[2], milestones) 100 | 101 | for (var i = 0; i < 3; i++) { 102 | 103 | var endpoint = stackedBar.stack[i].selectAll("line").nodes()[milestones[2-i]] 104 | var stack = endpoint.getBBox() 105 | var ctm = endpoint.getCTM() 106 | if (milestones[2-i] < 150) { 107 | lines[i].attr("x2", stack.x) 108 | .attr("y2", stack.y + 5) 109 | .attr("x1", stack.x) 110 | .attr("y1", 203.5 + seperation*(i)) 111 | .style("visibility", "visible") 112 | r[i].attr("marker-end", "url()") 113 | } else { 114 | lines[i].style("visibility", "hidden") 115 | r[i].attr("marker-end", "url(#arrowhead" + i + ")") 116 | } 117 | //setTM(lines[i].node(), ctm) // transform the lines into stackedplot space 118 | r[i].attr("x2", (stackedBar.X(milestones[2-i]) - 2) + "px") 119 | 120 | //setTM(r[i].node(), ctm) // transform the lines into stackedplot space 121 | setTM(progressmeter.node(), ctm) 122 | } 123 | } 124 | 125 | updateStep(100*2/(101.5), 0) 126 | 127 | return updateStep 128 | } -------------------------------------------------------------------------------- /public/assets/phasediagram.js: -------------------------------------------------------------------------------- 1 | function phaseDiagram(divin) { 2 | 3 | var totalIters = 100 4 | var default_underdamp = 0.97 5 | var default_overdamp = 0.05 6 | 7 | function getTrace(alpha, beta, coord, sign) { 8 | var m = [] 9 | var lambda = [1,100] 10 | var iter = geniterMomentum([[1, 0],[0, 1]], lambda, [1,sign*100], alpha, beta).iter 11 | // run for 500 iterations 12 | for (var i = 0; i <= totalIters; i++) { 13 | var x = numeric.add(iter(i)[1],-sign*1) 14 | var y = numeric.mul(iter(i)[0],(1/200)) 15 | m.push([y[coord], x[coord]]) 16 | } 17 | mG = m 18 | return m 19 | } 20 | 21 | var textCaptions = ["
Overdamping
When " + MathCache("beta") + " is too small (e.g. in Gradient Descent, " + MathCache("beta-equals-zero") + "), we're over-damping. The particle is immersed in a viscous fluid which saps it of its kinetic energy at every timestep.", 22 | "
Critical Damping
The best value of " + MathCache("beta") + " lies in the middle of the two extremes. This sweet spot happens when the eigenvalues of " + MathCache("r") + " are repeated, when " + MathCache("beta-equals-one-minus") + ".", 23 | "
Underdamping
When " + MathCache("beta") + " is too large we're under-damping. Here the resistance is too small, and spring oscillates up and down forever, missing the optimal value over and over. "] 24 | 25 | var al = 0.0001 26 | var optbeta = Math.pow(1 - Math.sqrt(al*100),2) 27 | 28 | var w = 170 29 | var h = 170 30 | var a = 1.0 31 | 32 | var axis = [[-a*5,a*5],[-a,a]] 33 | var width_bar = 620 34 | var X = d3.scaleLinear().domain([1,0]).range([0, width_bar]) 35 | 36 | var valueline = d3.line() 37 | .x(function(d) { return d[0]; }) 38 | .y(function(d) { return d[1]; }); 39 | 40 | var overlay = divin.append("svg") 41 | .style("position", "absolute") 42 | .attr("width", 648) 43 | .attr("height", 520) 44 | .style("z-index", 10) 45 | .style("pointer-events", "none") 46 | renderDraggable(overlay, [320.5, 361+35], [346.5, 378+35], 6, "reachesoptimum") 47 | //renderDraggable(overlay, [102, 312], [107, 310], 6, "initial point:x = 1, y = 0") 48 | //renderDraggable(overlay, [581.5, 360+35], [597.5, 321+35], 6, "misses optimum") 49 | 50 | // Draw the three phases 51 | var updateCallbacks = [] 52 | var divs = [] 53 | var ringPath = ringPathGen(5, 0, 0) 54 | var paths = [] 55 | for (var i = 0; i < 3; i ++ ) { 56 | 57 | var div = divin.append("div") 58 | .style("position","absolute") 59 | .style("width",w + "px") 60 | .style("height",h + "px") 61 | .style("left", [455, 235, 15][i] + "px") 62 | .style("top", [110, 110, 110][i] + "px") 63 | .style("border-top", "solid 1px gray") 64 | 65 | divs.push(div) 66 | var z = div.node() 67 | 68 | var divx = z.offsetLeft + z.offsetWidth/2 69 | var divy = z.offsetTop 70 | var path = overlay.append("path") 71 | .style("stroke", "grey") 72 | .style("stroke-width", "1px") 73 | .style("fill", "none") 74 | .attr("stroke-dasharray", "5,3") 75 | .attr("opacity", 0.7) 76 | 77 | if (i == 0) { 78 | 79 | var updateAnnotationOverDamp = (function(pathin, divxin, divyin) { 80 | return function(x,y,d) { 81 | pathin.transition().duration(d).attr("d", ringPath([x+10,y],[divxin,divyin]).d) 82 | } 83 | })(path, divx, divy) 84 | updateAnnotationOverDamp(X(default_overdamp), 30, 0) 85 | } 86 | 87 | if (i == 1) { 88 | path.attr("d", ringPath([X(0.8)+5,30],[divx - 40,divy -40]).d + "L" + divx + "," + divy + " ") 89 | } 90 | 91 | if (i == 2) { 92 | 93 | var updateAnnotationUnderDamp = (function(pathin, divxin, divyin) { 94 | return function(x,y,d) { 95 | pathin.transition().duration(d).attr("d", ringPath([x+10,y],[divxin,divyin]).d) 96 | } 97 | })(path, divx, divy) 98 | updateAnnotationUnderDamp(X(default_underdamp), 30, 0) 99 | 100 | } 101 | 102 | paths.push(path) 103 | 104 | div.append("figcaption") 105 | .style("position","absolute") 106 | .style("width", "180px") 107 | .style("height", "200px") 108 | .style("text-align", "left") 109 | .style("top", [10, 10, 10][i] + "px") 110 | .style("left", "00px") 111 | .html(textCaptions[i]) 112 | 113 | var svg = div.append("svg") 114 | .style("position", 'absolute') 115 | .style("left", 0) 116 | .style("top", "200px") 117 | .style("width", w) 118 | .style("height", h) 119 | .style("border-radius", "5px") 120 | 121 | svg.append("g").attr("class", "grid") 122 | .attr("transform", "translate(0," + h/2 +")") 123 | .attr("opacity", 0.2) 124 | .call(d3.axisBottom(X).ticks(0).tickSize(0)) 125 | 126 | svg.append("g").attr("class", "grid") 127 | .attr("transform", "translate(" + w/2 + ",0)") 128 | .attr("opacity", 0.2) 129 | .call(d3.axisLeft(X).ticks(0).tickSize(0)) 130 | 131 | var colorRange = d3.scaleLinear().domain([0, totalIters/16, totalIters/2]).range(colorbrewer.OrRd[3]) 132 | 133 | var Xaxis = d3.scaleLinear().domain(axis[0]).range([0, w]) 134 | var Yaxis = d3.scaleLinear().domain(axis[1]).range([0, h]) 135 | 136 | var update = plot2dGen(Xaxis, Yaxis, colorRange) 137 | .pathOpacity(1) 138 | .pathWidth(1.5) 139 | .circleRadius(1.5) 140 | .stroke(colorbrewer.OrRd[3][0])(svg) 141 | 142 | update(getTrace(al, [0.01, optbeta + 0.0001 , default_underdamp][i], 1,1)) 143 | updateCallbacks.push(update) 144 | 145 | } 146 | 147 | var linesvg = divin 148 | .append("svg") 149 | 150 | // Axis 151 | var axis = linesvg.append("g") 152 | .attr("class", "figtext") 153 | .attr("opacity", 0.3) 154 | .attr("transform", "translate(0,32)") 155 | .call(d3.axisBottom(X) 156 | .ticks(5) 157 | .tickSize(5)) 158 | 159 | axis.selectAll("path").remove() 160 | axis.select("text").style("text-anchor", "start"); 161 | 162 | var html = MathCache("beta"); 163 | // Axis 164 | linesvg.append("text") 165 | .attr("class", "figtext") 166 | .attr("opacity", 1) 167 | .attr("transform", "translate(0,12)") 168 | .html("Momentum β") 169 | 170 | linesvg.style("position","absolute") 171 | .style("width", "920px") 172 | .style("height", "570px") 173 | .style("left", "10px") 174 | .append("line") 175 | .attr("x1", 0) 176 | .attr("y1", 30) 177 | .attr("x2", 0 + width_bar) 178 | .attr("y2", 30) 179 | .style("border", "solid 2px black") 180 | .style("stroke", "#CCC") 181 | .style("fill", "white") 182 | .style("stroke-width", "1.5px") 183 | 184 | var underdamp = linesvg 185 | .append("circle") 186 | .attr("cx", X(default_overdamp)) 187 | .attr("cy", 30) 188 | .attr("r", 6) 189 | .style("fill", "#ff6600") 190 | 191 | var criticaldamp = linesvg 192 | .append("circle") 193 | .attr("cx", X(optbeta)) 194 | .attr("cy", 30) 195 | .attr("r", 6) 196 | .style("fill", "#ff6600") 197 | 198 | var overdamp = linesvg 199 | .append("circle") 200 | .attr("cx", X(default_underdamp)) 201 | .attr("cy", 30) 202 | .attr("r", 6) 203 | .style("fill", "#ff6600") 204 | 205 | var prevState = "" 206 | 207 | linesvg.style("position","absolute") 208 | .style("width", "920px") 209 | .style("height", "570px") 210 | .append("line") 211 | .attr("x1", 0) 212 | .attr("y1", 30) 213 | .attr("x2", 0 + width_bar) 214 | .attr("y2", 30) 215 | .style("border", "solid 2px black") 216 | .style("stroke", "black") 217 | .style("fill", "white") 218 | .style("opacity", 0) 219 | .style("z-index", 3) 220 | .style("stroke-width", "40px") 221 | .on("mousemove", function () { 222 | 223 | var pt = d3.mouse(this) 224 | var beta = X.invert(pt[0]) 225 | if (beta < optbeta) { 226 | underdamp.attr("cx", pt[0]) 227 | updateCallbacks[0](getTrace(al, X.invert(pt[0]), 1,1)) 228 | 229 | overdamp.attr("cx", X(default_underdamp)) 230 | updateAnnotationOverDamp(pt[0], 30, 0) 231 | 232 | if (prevState != "Over"){ 233 | divs[0].style("opacity",1) 234 | divs[1].style("opacity",0.2) 235 | divs[2].style("opacity",0.2) 236 | 237 | updateCallbacks[2](getTrace(al, default_underdamp, 1,1)) 238 | updateAnnotationUnderDamp(X(default_underdamp), 30, 20) 239 | } 240 | prevState = "Over" 241 | } 242 | if (beta > optbeta) { 243 | overdamp.attr("cx", pt[0]) 244 | underdamp.attr("cx", X(default_overdamp)) 245 | updateCallbacks[2](getTrace(al, Math.min(X.invert(pt[0]),1), 1,1)) 246 | 247 | updateAnnotationUnderDamp(pt[0], 30, 0) 248 | 249 | if (prevState != "Under") { 250 | divs[0].style("opacity",0.2) 251 | divs[1].style("opacity",0.2) 252 | divs[2].style("opacity",1) 253 | 254 | updateCallbacks[0](getTrace(al, default_overdamp, 1,1)) 255 | updateAnnotationOverDamp(X(default_overdamp), 30, 20) 256 | } 257 | prevState = "Under" 258 | } 259 | 260 | }) 261 | .on("mouseout", function () { 262 | divs[0].style("opacity",1) 263 | divs[1].style("opacity",1) 264 | divs[2].style("opacity",1) 265 | 266 | underdamp.transition().duration(50).attr("cx", X(default_overdamp)) 267 | updateCallbacks[0](getTrace(al, default_overdamp, 1,1)) 268 | 269 | overdamp.transition().duration(50).attr("cx", X(default_underdamp)) 270 | updateCallbacks[2](getTrace(al, default_underdamp, 1,1)) 271 | 272 | updateAnnotationUnderDamp(X(default_underdamp), 30, 50) 273 | updateAnnotationOverDamp(X(default_overdamp), 30, 50) 274 | prevState = "" 275 | 276 | }) 277 | 278 | 279 | 280 | } 281 | -------------------------------------------------------------------------------- /public/assets/phasediagram_description.js: -------------------------------------------------------------------------------- 1 | function phaseDiagram_dec(divin) { 2 | 3 | var totalIters = 250 4 | var default_underdamp = 0.97 5 | var default_overdamp = 0.05 6 | 7 | function myRunMomentum(f, w0, alpha, beta, totalIters) { 8 | var W = []; var Z = []; var z = zeros(w0.length); var w = w0 9 | z[1] = 1 10 | var gx = f(w0); 11 | W.push(w0); 12 | Z.push(numeric.mul(-1,z)); 13 | for (var i = 0; i < totalIters; i++) { 14 | var z = numeric.add(numeric.mul(beta, z), gx) 15 | var w = numeric.add(w, numeric.mul(-alpha, z)) 16 | gx = f(w); 17 | if (w.every(isFinite)) { 18 | W.push(w) 19 | Z.push(numeric.mul(-1, z)) 20 | } else{ break; } 21 | } 22 | return [Z,W] 23 | } 24 | 25 | function getTrace(alpha, beta, lambda) { 26 | var m = [] 27 | var iter = myRunMomentum(function(x) { return [x[0],lambda*x[1]] }, [2,0.92], alpha, beta, totalIters) 28 | // run for 500 iterations 29 | for (var i = 0; i <= totalIters; i++) { 30 | var x = -1*iter[1][i][1] 31 | var y = (1.4)*iter[0][i][1] 32 | m.push([y, x]) 33 | } 34 | mG = m 35 | return m 36 | } 37 | 38 | var al = 0.0001 39 | var optbeta = Math.pow(1 - Math.sqrt(al*100),2) 40 | 41 | var w = 95 42 | var h = 95 43 | var a = 1.0 44 | 45 | var axis = [[-a*5,a*5],[-a,a]] 46 | var width_bar = 620 47 | var X = d3.scaleLinear().domain([0,1]).range([0, width_bar]) 48 | 49 | var valueline = d3.line() 50 | .x(function(d) { return d[0]; }) 51 | .y(function(d) { return d[1]; }); 52 | 53 | var overlay = divin.append("svg") 54 | .style("position", "absolute") 55 | .attr("width", 348) 56 | .attr("height", 620) 57 | .style("z-index", 10) 58 | .style("pointer-events", "none") 59 | 60 | // Draw the three phases 61 | 62 | var lambdas = [0, 0.02, 0.1, 0.25] 63 | var betas = [1, 0.985, 0.95, 0.9, 0.85, 0.8, 0] 64 | 65 | for (var i = 0; i < 6; i ++ ) { 66 | divin.append("figcaption") 67 | .style("position","absolute") 68 | .style("width",(w-10) + "px") 69 | .style("height",20 + "px") 70 | .style("left", 65 + (w+14)*i + "px") 71 | .style("top", 0 + "px") 72 | .attr("class", "figtext") 73 | .style("border-bottom", "1px solid black" ) 74 | .html((i != 0 ? "" : "β = ") + betas[i]) 75 | } 76 | 77 | for (var j = 0; j < 4; j ++ ) { 78 | divin.append("figcaption") 79 | .style("position","absolute") 80 | .style("width", 35 + "px") 81 | .style("height", h + "px") 82 | .style("left", 0 + "px") 83 | .style("top", 50 + 125*j + "px") 84 | .attr("class", "figtext") 85 | .style("border-right", "1px solid black" ) 86 | .html( (j != 0 ? " " : "
λ = ") + lambdas[j]) 87 | } 88 | 89 | divin.append("figcaption") 90 | .style("position","absolute") 91 | .style("width",35 + "px") 92 | .style("height",h + "px") 93 | .style("left", 90 + "px") 94 | .style("top", 27 + "px") 95 | .html( "Velocity") 96 | 97 | divin.append("figcaption") 98 | .style("position","absolute") 99 | .style("width",100 + "px") 100 | .style("height",h + "px") 101 | .style("left", 64 + "px") 102 | .style("top", -17 + "px") 103 | .attr("class", "figtext") 104 | .html( "Damping") 105 | 106 | divin.append("figcaption") 107 | .style("position","absolute") 108 | .style("width",100 + "px") 109 | .style("height",h + "px") 110 | .style("left", -55 + "px") 111 | .style("top", 50 + "px") 112 | .attr("class", "figtext") 113 | .html( "External Force") 114 | 115 | divin.append("figcaption") 116 | .style("position","absolute") 117 | .style("width",35 + "px") 118 | .style("height",h + "px") 119 | .style("left", 75 + "px") 120 | .style("top", 56 + "px") 121 | .style("transform","rotate(-90deg)") 122 | .html( "Position") 123 | 124 | divin.append("figcaption") 125 | .style("position","absolute") 126 | .style("width",120 + "px") 127 | .style("height",h + "px") 128 | .style("left", 730 + "px") 129 | .style("top", 60 + "px") 130 | .style("font-size", "12px") 131 | .html("" + MathCache("beta") + ": Horizontal Axis
When " + MathCache("lambda-i-equals-zero") + " and " + MathCache("beta-equals-one") + ", the object moves at constant speed. As " + MathCache("beta") + " goes down, the particle decelerates, losing a proportion of its energy at each tick. ") 132 | 133 | divin.append("figcaption") 134 | .style("position","absolute") 135 | .style("width",120 + "px") 136 | .style("height",h + "px") 137 | .style("left", 730 + "px") 138 | .style("top", (120*2 + 50) + "px") 139 | .style("font-size", "12px") 140 | .html(" " + MathCache("lambda") + ": Vertical Axis
The external force causes the particle to return to the origin. Combining damping and the force field, the particle behaves like a damped harmonic oscillator, returning lazily to equlibrium.") 141 | 142 | for (var i = 0; i < 6; i ++ ) { 143 | for (var j = 0; j < 4; j ++) { 144 | 145 | var hborder = (j == 0) ? 0 : 35 146 | 147 | var div = divin.append("div") 148 | .style("position","absolute") 149 | .style("width", w + "px") 150 | .style("height",h + "px") 151 | .style("left", 65 + (w+14)*i + "px") 152 | .style("top", 50 + 125*j - hborder + "px") 153 | 154 | var svg = div.append("svg") 155 | .style("position", 'absolute') 156 | .style("left", 0) 157 | .style("top", "px") 158 | .style("width", w) 159 | .style("height", h + (2*hborder)) 160 | .style("border-radius", "5px") 161 | 162 | svg.append("g").attr("class", "grid") 163 | .attr("transform", "translate(0," + (h + 2*hborder)/2 +")") 164 | .attr("opacity", 0.2) 165 | .call(d3.axisBottom(X).ticks(0).tickSize(0)) 166 | 167 | svg.append("g").attr("class", "grid") 168 | .attr("transform", "translate(" + w/2 + ",0)") 169 | .attr("opacity", 0.2) 170 | .call(d3.axisLeft(d3.scaleLinear().domain([0,1]).range([hborder, h+hborder])).ticks(0).tickSize(0)) 171 | 172 | var colorRange = d3.scaleLinear().domain([0, 10, 50, totalIters]).range(colorbrewer.OrRd[4]) 173 | 174 | var Xaxis = d3.scaleLinear().domain(axis[0]).range([0, w]) 175 | var Yaxis = d3.scaleLinear().domain(axis[1]).range([hborder, h+hborder]) 176 | 177 | var update = plot2dGen(Xaxis, Yaxis, colorRange) 178 | .pathOpacity(1) 179 | .pathWidth(0.5) 180 | .circleRadius(1) 181 | .stroke(colorbrewer.OrRd[5][2])(svg) 182 | 183 | update(getTrace(0.02, betas[i], lambdas[j])) 184 | } 185 | } 186 | 187 | 188 | 189 | } -------------------------------------------------------------------------------- /public/assets/stochastic_milestones.js: -------------------------------------------------------------------------------- 1 | Math.randn = function() { 2 | var x1, x2, rad, y1; 3 | do { 4 | x1 = 2 * this.random() - 1; 5 | x2 = 2 * this.random() - 1; 6 | rad = x1 * x1 + x2 * x2; 7 | } while(rad >= 1 || rad == 0); 8 | var c = this.sqrt(-2 * Math.log(rad) / rad); 9 | return x1 * c; 10 | }; 11 | 12 | function renderStochasticMilestones(div, updateTick) { 13 | 14 | var lambda = [1,10,100] 15 | var totalIters = 151 16 | 17 | div.append("defs").append("marker") 18 | .attr("id", "arrowhead") 19 | .attr("refX", 3) 20 | .attr("refY", 2) 21 | .attr("markerWidth", 4) 22 | .attr("markerHeight", 4) 23 | .attr("orient", "auto") 24 | .append("path") 25 | .attr("d", "M 0,0 V 4 L4,2 Z"); //this is actual shape for arrowhead 26 | 27 | var lam = 1 28 | var epsilon = 3 29 | 30 | var f = function(x) { 31 | var fx = 0.5*(lam*x[0]*x[0]) 32 | var g = [lam*x[0]] 33 | return [fx, g] 34 | } 35 | 36 | 37 | var stochasticf = function(x) { 38 | var fx = 0.5*(lam*x[0]*x[0]) 39 | var g = [lam*x[0] + epsilon*Math.randn()] 40 | return [fx, g] 41 | } 42 | 43 | 44 | /* 45 | Gets information about iterates with certain parameter alpha and beta. 46 | > v = getTrace(0.5, 0) 47 | v[0] -> z iterates 48 | v[1] -> w iterates 49 | v[2] -> [c1, c2, c3] where c1, c2, c3 are the contributions to the loss 50 | */ 51 | function getTrace(alpha, beta) { 52 | 53 | var Rmat = function (i) { 54 | return [[ beta, lam ], 55 | [ -1*alpha*beta, 1 - alpha*lam ]] 56 | } 57 | 58 | var R = Rmat(1) 59 | var w0 = [Math.sqrt(3)] 60 | var v = runMomentum(f, w0, alpha, beta, totalIters) 61 | var fxstack = [] 62 | var errx = [epsilon, -alpha*epsilon] 63 | var errsum = 0 64 | 65 | var nsamples = 1 66 | svsamples = [] 67 | for (var i = 0; i < nsamples; i++) { 68 | var sv = runMomentum(stochasticf, w0, alpha, beta, totalIters) 69 | svsamples.push(sv[1]) 70 | } 71 | fxaverage = [] 72 | for (var i = 0; i < v[0].length; i++) { 73 | var mean = 0 74 | for (var j = 0; j < nsamples; j++) { 75 | mean = mean + (lam*svsamples[j][i][0]*svsamples[j][i][0])/2 76 | } 77 | fxaverage.push([mean/nsamples]) 78 | } 79 | var stochasticfx = [] 80 | // Add contributions to the objective 81 | for (var i = 0; i < v[0].length; i++) { 82 | errsum = errsum + errx[1]*errx[1]/2 83 | errx = numeric.dot(R, errx) 84 | var x = v[1][i] 85 | fxstack.push([errsum, lam*x[0]*x[0]/2]) 86 | stochasticfx.push([lam*sv[1][i][0]*sv[1][i][0]/2]) 87 | } 88 | v.push(fxstack) 89 | 90 | return {deterministic:v, stochastic:fxaverage} 91 | } 92 | 93 | 94 | var stackedBar = stackedBarchartGen(totalIters, 2) 95 | .col(colorbrewer.BuPu) 96 | .translatey(30) 97 | .translatex(110) 98 | .highlightcol("darkblue")(div) 99 | 100 | 101 | var stackedBar2 = stackedBarchartGen(totalIters, 1) 102 | .col(colorbrewer.BuPu) 103 | .translatey(30) 104 | .translatex(110) 105 | .cr(1.2) 106 | .copacity(0.5) 107 | .lineopacity(0) 108 | .drawgrid(false) 109 | .highlightcol("darkblue")(div) 110 | 111 | 112 | div.append("rect") 113 | .attr("x", 0) 114 | .attr("y", 0) 115 | .attr("width", 1000) 116 | .attr("height", 30) 117 | .attr("fill", "white") 118 | 119 | var seperation = 14 120 | 121 | 122 | var progressmeter = div.append("g") 123 | 124 | var textl = progressmeter.append("g") 125 | 126 | textl.append("line") 127 | .attr("y1",-5) 128 | .attr("y2",-5) 129 | .attr("x1",110) 130 | .attr("x2",120) 131 | .attr("stroke","black") 132 | .attr("stroke-width", 1.5) 133 | .attr("marker-end", "url(#arrowhead)") 134 | 135 | textl.append("text") 136 | .attr("class", "figtext2") 137 | .text("Fine-tuning phase") 138 | 139 | var textr = progressmeter.append("g") 140 | 141 | textr.append("text") 142 | .attr("class", "figtext2") 143 | .attr("text-anchor", "end") 144 | .text("Transient phase") 145 | 146 | 147 | textr.append("line") 148 | .attr("y1",-5) 149 | .attr("y2",-5) 150 | .attr("x1",-100) 151 | .attr("x2",-110) 152 | .attr("stroke","black") 153 | .attr("stroke-width", 1.5) 154 | .attr("marker-end", "url(#arrowhead)") 155 | 156 | var divider2 = progressmeter.append("line") 157 | .style("stroke", "white") 158 | .style("stroke-width",5) 159 | .attr("opacity", 0.9) 160 | 161 | var divider = progressmeter.append("line") 162 | .style("stroke", "black") 163 | .style("stroke-width",1.5) 164 | .attr("opacity", 0.9) 165 | 166 | var updateStep = function(alpha, beta) { 167 | var tracebath = getTrace(alpha/lambda[2], beta) 168 | var trace = tracebath.deterministic 169 | var strace = tracebath.stochastic 170 | 171 | // Update the milestones on the slider 172 | var milestones = [0,0] 173 | for (var i = 0; i < trace[1].length; i++) { 174 | if (trace[2][i][1] > trace[2][i][0]) { milestones[0] = i; milestones[1] = i; } else { break} 175 | } 176 | stackedBar.update(trace[2], milestones) 177 | stackedBar2.update(strace, milestones) 178 | var endpoint = stackedBar.stack[0].selectAll("line").nodes()[milestones[0]] 179 | var stack = endpoint.getBBox() 180 | var ctm = endpoint.getCTM() 181 | 182 | if (milestones[0] < 150) { 183 | textl.attr("transform", "translate(" + (stack.x + 10) + ",-15)").style("visibility", "visible") 184 | textr.attr("transform", "translate(" + (stack.x - 10) + ",-16)").style("visibility", "visible") 185 | divider.attr("x2", stack.x) 186 | .attr("y2", -25) 187 | .attr("x1", stack.x) 188 | .attr("y1", 160) 189 | .style("visibility", "visible") 190 | divider2.attr("x2", stack.x) 191 | .attr("y2", -25) 192 | .attr("x1", stack.x) 193 | .attr("y1", 160) 194 | .style("visibility", "visible") 195 | } else { 196 | endpointend = stackedBar.stack[0].selectAll("line").nodes()[149].getBBox().x 197 | console.log(endpointend) 198 | textr.attr("transform", "translate(" + (endpointend + 10) + ",-16)").style("visibility", "visible") 199 | divider.style("visibility", "hidden") 200 | textl.style("visibility", "hidden") 201 | divider2.style("visibility", "hidden") 202 | } 203 | setTM(progressmeter.node(), ctm) 204 | 205 | } 206 | 207 | updateStep(100*2/(101.5), 0) 208 | 209 | return updateStep 210 | } -------------------------------------------------------------------------------- /public/assets/widgets.css: -------------------------------------------------------------------------------- 1 | 2 | .ticks { 3 | font: 10px sans-serif; 4 | } 5 | 6 | .track, 7 | .track-inset, 8 | .track-overlay { 9 | stroke-linecap: round; 10 | 11 | } 12 | 13 | .track { 14 | stroke: #e6e6e6; 15 | stroke-opacity: 0.5; 16 | stroke-width: 2px; 17 | } 18 | 19 | .track-inset { 20 | stroke: #e6e6e6; 21 | stroke-width: 5px; 22 | 23 | } 24 | 25 | .track-overlay { 26 | pointer-events: stroke; 27 | stroke-width: 50px; 28 | stroke: rgba(0,0,0,0) 29 | } 30 | 31 | .handle { 32 | fill: #fff; 33 | fill-opacity: 0.2; 34 | stroke: #000; 35 | stroke-opacity: 0.5; 36 | stroke-width: 1.5px; 37 | } 38 | 39 | .figtext path{ 40 | stroke: black; 41 | stroke-width:1; 42 | fill: none; 43 | } 44 | 45 | /* Tooltip Styles */ 46 | 47 | .d3-tip { 48 | line-height: 1; 49 | font-weight: bold; 50 | padding: 5px; 51 | background: rgba(0, 0, 0, 0.8); 52 | color: #fff; 53 | border-radius: 2px; 54 | pointer-events: none; 55 | font-size: 10px; 56 | } 57 | 58 | /* Creates a small triangle extender for the tooltip */ 59 | .d3-tip:after { 60 | box-sizing: border-box; 61 | display: inline; 62 | font-size: 10px; 63 | width: 100%; 64 | line-height: 1; 65 | color: rgba(0, 0, 0, 0.8); 66 | position: absolute; 67 | pointer-events: none; 68 | } 69 | 70 | /* Northward tooltips */ 71 | .d3-tip.n:after { 72 | content: "\25BC"; 73 | margin: -1px 0 0 0; 74 | top: 100%; 75 | left: 0; 76 | text-align: center; 77 | } 78 | 79 | /* Eastward tooltips */ 80 | .d3-tip.e:after { 81 | content: "\25C0"; 82 | margin: -4px 0 0 0; 83 | top: 50%; 84 | left: -8px; 85 | } 86 | 87 | /* Southward tooltips */ 88 | .d3-tip.s:after { 89 | content: "\25B2"; 90 | margin: 0 0 1px 0; 91 | top: -8px; 92 | left: 0; 93 | text-align: center; 94 | } 95 | 96 | /* Westward tooltips */ 97 | .d3-tip.w:after { 98 | content: "\25B6"; 99 | margin: -4px 0 0 -1px; 100 | top: 50%; 101 | left: 100%; 102 | } 103 | 104 | #eigenFeatures .stage { 105 | position: relative; 106 | margin-bottom: 24px; 107 | } 108 | #eigenFeatures .waveform { 109 | position: absolute; 110 | opacity: 0.7; 111 | } 112 | #eigenFeatures .pointer { 113 | position: absolute; 114 | width: 26px; 115 | height: 26px; 116 | top: 36px; 117 | left: -48px; 118 | } 119 | #eigenFeatures svg { 120 | z-index: 1; 121 | position: absolute; 122 | margin-left:auto; 123 | margin-right:auto; 124 | width: 920px; 125 | 126 | } 127 | #eigenFeatures svg .labels { 128 | font-size: 12px; 129 | fill-opacity: 0.5; 130 | } 131 | #eigenFeatures figcaption { 132 | text-align: center; 133 | } 134 | #eigenFeatures .background { 135 | fill: rgb(240, 240, 245); 136 | fill-opacity: 0.1; 137 | border:solid 1px black; 138 | } 139 | #eigenFeatures .audio-background { 140 | fill: none; 141 | stroke: black; 142 | stroke-opacity: 0.3; 143 | } 144 | #eigenFeatures .cell .node { 145 | fill: white; 146 | fill-opacity: 0.5; 147 | stroke: black; 148 | stroke-width: 1.5px; 149 | stroke-opacity: 0.5; 150 | } 151 | #eigenFeatures .cell:hover .node { 152 | stroke-opacity: 1; 153 | fill:#7570b3; 154 | stroke:#7570b3; 155 | stroke-width: 2.0px; 156 | } 157 | #eigenFeatures .cell .shadow { 158 | fill: black; 159 | fill-opacity: 0.07; 160 | } 161 | #eigenFeatures .cell text { 162 | font-size: 13px; 163 | fill-opacity: 0.5; 164 | text-anchor: middle; 165 | alignment-baseline: middle; 166 | } 167 | #eigenFeatures .cell text.label { 168 | font-size: 10px; 169 | /*fill-opacity: 0.8;*/ 170 | text-anchor: middle; 171 | alignment-baseline: middle; 172 | } 173 | 174 | #eigenFeatures .link-group { 175 | transition: opacity, 0.3s, linear; 176 | } 177 | #eigenFeatures .link-group .node-highlight { 178 | transition: stroke-opacity, 0.3s, linear; 179 | stroke: black; 180 | stroke-opacity: 0; 181 | fill: none; 182 | } 183 | #eigenFeatures .link-group:hover .node-highlight { 184 | stroke-opacity: 1; 185 | } 186 | #eigenFeatures .link { 187 | fill: none; 188 | stroke: black; 189 | stroke-width: 1.5px; 190 | pointer-events: none; 191 | } 192 | #eigenFeatures .arrow { 193 | stroke: black; 194 | stroke-opacity: 0.3; 195 | } 196 | #eigenFeatures .cell:last-child .arrow:first-of-type { 197 | display: none; 198 | } 199 | #eigenFeatures .tick { 200 | stroke: black; 201 | stroke-opacity: 0.2; 202 | } 203 | 204 | 205 | .figtext{ 206 | font-size:12px; 207 | line-height:18px; 208 | font-family:Helvetica; 209 | font-weight: bold; 210 | } 211 | 212 | .figtext2{ 213 | font-size:13px; 214 | line-height:18px; 215 | font-family:Helvetica; 216 | text-align:left; 217 | color:gray; 218 | } 219 | 220 | 221 | .annotatetext{ 222 | font-size:12px; 223 | line-height:18px; 224 | font-family:Helvetica; 225 | color:gray; 226 | } 227 | 228 | .annotatetext path{ 229 | stroke: black; 230 | stroke-width:1; 231 | fill: none; 232 | } 233 | 234 | 235 | .ticktext{ 236 | font-size:12px; 237 | line-height:18px; 238 | font-family:Helvetica; 239 | text-align:right; 240 | } 241 | 242 | .mycaptiontext{ 243 | font-size:15px; 244 | line-height:22px !important; 245 | font-family:Open Sans; 246 | text-align:right; 247 | color:gray; 248 | } 249 | 250 | 251 | .links line { 252 | stroke: #000; 253 | stroke-opacity: 1; 254 | } 255 | 256 | .nodes circle { 257 | stroke: #000; 258 | stroke-width: 1px; 259 | } 260 | .axis line, .axis path { 261 | fill: none; 262 | stroke: #000; 263 | shape-rendering: crispEdges; 264 | } 265 | 266 | .annotations path{ 267 | fill: none; 268 | stroke: black; 269 | } 270 | .annotations g:hover circle{ 271 | stroke: red; 272 | } 273 | .annotations g:hover text{ 274 | fill: red; 275 | } 276 | 277 | .draggable-number > .katex { 278 | /*hsl(24, 100%, 50%)*/ 279 | border-bottom: dotted 1px #bbb; 280 | /*color: hsl(24, 100%, 45%);*/ 281 | padding-bottom: 4px; 282 | } 283 | 284 | .draggable-number:hover > .katex { 285 | color: hsl(24, 100%, 45%); 286 | border-bottom: dotted 1px hsl(24, 100%, 50%); 287 | } 288 | -------------------------------------------------------------------------------- /public/examples/2dslider_widget.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |

18 | Hold down the left mouse button and drag in the Comp window to create a paragraph text block. The edge—the text’s bounding box— is defined by how far you dragged the mouse when you created the paragraph text layer. This style of text wraps text to the next line when your type reaches the edge of the current line. 19 |

20 | 21 |
22 | 23 | 27 |

28 | Hold down the left mouse button and drag in the Comp window to create a paragraph text block. The edge—the text’s bounding box— is defined by how far you dragged the mouse when you created the paragraph text layer. This style of text wraps text to the next line when your type reaches the edge of the current line. 29 |

30 |
31 | 32 | -------------------------------------------------------------------------------- /public/examples/annotate.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 33 | 34 |
35 | 36 | -------------------------------------------------------------------------------- /public/examples/annotate_shan.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 29 | 30 |
Radius
31 | 32 | 33 |
34 |
35 | 36 | 37 | 38 | 39 | 172 | -------------------------------------------------------------------------------- /public/examples/banana_widget.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 34 | 41 | 44 | 47 | 50 | 54 | 56 | 58 | 59 | 60 |
61 | 62 |
63 | 64 |
65 | Step-size α = 0.02 66 |
67 | 68 |
69 | Momentum β = 0.99 70 |
71 | 72 |
73 | 74 | The Rosenbrock banana function is famous for its pathological curvature. The landscapes are often described as a valleys, trenches, canals, ravines. In these steep valleys, gradient descent fumbles. But 75 | 76 |
77 |
78 | 79 | 115 | 116 | -------------------------------------------------------------------------------- /public/examples/change_basis_widget.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 |
13 |
14 |
15 | 61 | 62 | -------------------------------------------------------------------------------- /public/examples/eigenfeatures_widget.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 20 | 21 | 22 | 23 |

24 | Hold down the left mouse button and drag in the Comp window to create a paragraph text block. The edge—the text’s bounding box— is defined by how far you dragged the mouse when you created the paragraph text layer. This style of text wraps text to the next line when your type reaches the edge of the current line. 25 |

26 | 119 | 120 | 366 |

367 | Hold down the left mouse button and drag in the Comp window to create a paragraph text block. The edge—the text’s bounding box— is defined by how far you dragged the mouse when you created the paragraph text layer. This style of text wraps text to the next line when your type reaches the edge of the current line. 368 |

369 |
370 | 371 | -------------------------------------------------------------------------------- /public/examples/eigensum.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |

17 | Hold down the left mouse button and drag in the Comp window to create a paragraph text block. The edge—the text’s bounding box— is defined by how far you dragged the mouse when you created the paragraph text layer. This style of text wraps text to the next line when your type reaches the edge of the current line. 18 |

19 | 20 | 21 |
22 | 23 | 92 |

93 | Hold down the left mouse button and drag in the Comp window to create a paragraph text block. The edge—the text’s bounding box— is defined by how far you dragged the mouse when you created the paragraph text layer. This style of text wraps text to the next line when your type reaches the edge of the current line. 94 |

95 |
96 | 97 | -------------------------------------------------------------------------------- /public/examples/eigensum2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |

18 | Hold down the left mouse button and drag in the Comp window to create a paragraph text block. The edge—the text’s bounding box— is defined by how far you dragged the mouse when you created the paragraph text layer. This style of text wraps text to the next line when your type reaches the edge of the current line. 19 |

20 | 21 | 22 | 23 |
24 | 25 | 91 | 92 |

93 | Hold down the left mouse button and drag in the Comp window to create a paragraph text block. The edge—the text’s bounding box— is defined by how far you dragged the mouse when you created the paragraph text layer. This style of text wraps text to the next line when your type reaches the edge of the current line. 94 |

95 |
96 | 97 | -------------------------------------------------------------------------------- /public/examples/eigensum3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |

18 | Hold down the left mouse button and drag in the Comp window to create a paragraph text block. The edge—the text’s bounding box— is defined by how far you dragged the mouse when you created the paragraph text layer. This style of text wraps text to the next line when your type reaches the edge of the current line. 19 |

20 | 21 |
22 | 23 | 85 |

86 | Hold down the left mouse button and drag in the Comp window to create a paragraph text block. The edge—the text’s bounding box— is defined by how far you dragged the mouse when you created the paragraph text layer. This style of text wraps text to the next line when your type reaches the edge of the current line. 87 |

88 |
89 | 90 | -------------------------------------------------------------------------------- /public/examples/flow_widget.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 42 | 43 | 44 |
45 | 46 | 74 | -------------------------------------------------------------------------------- /public/examples/force-layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |

25 | Instead of taking taking a step in the gradient, we move in a geometrically decaying superposition all the previous gradients. When $ \beta = 0 $ , we recover gradient descent. But for $ \beta = 0.99 $ (sometimes $ 0.999$, if things are really bad), the situation improves quite dramatically. 26 | 27 |

28 |
29 | 30 |
Small world graphs, like expanders and dense graphs, have excellent conditioning
31 | 32 |
The conditioning of grids improves with its dimensionality.
33 | 34 |
And long, wiry graphs, like paths, condition poorly.
35 | 36 |
37 | 47 | 48 |
-------------------------------------------------------------------------------- /public/examples/hozbar_widget.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 |

18 | Hold down the left mouse button and drag in the Comp window to create a paragraph text block. The edge—the text’s bounding box— is defined by how far you dragged the mouse when you created the paragraph text layer. This style of text wraps text to the next line when your type reaches the edge of the current line. 19 |

20 | 21 |
22 | 23 | 59 |

60 | Hold down the left mouse button and drag in the Comp window to create a paragraph text block. The edge—the text’s bounding box— is defined by how far you dragged the mouse when you created the paragraph text layer. This style of text wraps text to the next line when your type reaches the edge of the current line. 61 |

62 |
63 | 64 | -------------------------------------------------------------------------------- /public/examples/linear_transform.html: -------------------------------------------------------------------------------- 1 | 97 | 98 | 344 | -------------------------------------------------------------------------------- /public/examples/milestones_widget.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |

16 | Instead of taking taking a step in the gradient, we move in a geometrically decaying superposition all the previous gradients. When $ \beta = 0 $ , we recover gradient descent. But for $ \beta = 0.99 $ (sometimes $ 0.999$, if things are really bad), the situation improves quite dramatically. 17 | 18 |

19 | 20 |
21 |
Optimization can be seen as combination of several component problems, shown here as a b c
22 | 23 |
24 |
25 |
26 | 53 |

54 | Instead of taking taking a step in the gradient, we move in a geometrically decaying superposition all the previous gradients. When $ \beta = 0 $ , we recover gradient descent. But for $ \beta = 0.99 $ (sometimes $ 0.999$, if things are really bad), the situation improves quite dramatically. 55 | 56 |

57 |
58 | 59 | -------------------------------------------------------------------------------- /public/examples/milestones_widget_momentum.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 30 | 31 |

32 | Instead of taking taking a step in the gradient, we move in a geometrically decaying superposition all the previous gradients. When $ \beta = 0 $ , we recover gradient descent. But for $ \beta = 0.99 $ (sometimes $ 0.999$, if things are really bad), the situation improves quite dramatically. 33 | 34 |

35 |
36 |
We decompose the expected value of the objective value $\mathbf{E} f(w) - f(w^*)$ into a deterministic part and a stochastic part . The line depicts the point where the expected errors match.
37 |
$\mathbf{E} f(w) - f(w^\star) $
38 |
Step-size α =
39 |
Momentum β =
40 | 41 |
42 |
43 |
44 | 80 |

81 | Instead of taking taking a step in the gradient, we move in a geometrically decaying superposition all the previous gradients. When $ \beta = 0 $ , we recover gradient descent. But for $ \beta = 0.99 $ (sometimes $ 0.999$, if things are really bad), the situation improves quite dramatically. 82 | 83 |

84 | 85 |
86 | 87 | -------------------------------------------------------------------------------- /public/examples/momentum_widget.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |

16 | Hold down the left mouse button and drag in the Comp window to create a paragraph text block. The edge—the text’s bounding box— is defined by how far you dragged the mouse when you created the paragraph text layer. This style of text wraps text to the next line when your type reaches the edge of the current line. 17 |

18 |
19 |
20 |
21 |
22 |
23 | Convergence Rate 24 | 25 |
26 | 27 |
28 | A plot of $\max{\sigma_1, \sigma_2}$ reveals distinct regions, each with its own style of convergence. 29 |
30 | 31 |
32 |
33 | 34 |
35 | 89 |

90 | Hold down the left mouse button and drag in the Comp window to create a paragraph text block. The edge—the text’s bounding box— is defined by how far you dragged the mouse when you created the paragraph text layer. This style of text wraps text to the next line when your type reaches the edge of the current line. 91 |

92 |
93 | 94 | -------------------------------------------------------------------------------- /public/examples/phase_diagram.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 28 | 29 | 30 | 31 |

32 | Hold down the left mouse button and drag in the Comp window to create a paragraph text block. The edge—the text’s bounding box— is defined by how far you dragged the mouse when you created the paragraph text layer. This style of text wraps text to the next line when your type reaches the edge of the current line. 33 | 34 | You can resize the bounding box by clicking to place the cursor within the text, then dragging on one of the sizing handles around the perimeter of the bounding box. Shift-dragging a sizing handle will constrain the proportions of the bounding box. Make sure you don’t accidentally drag a sizing handle with the Selection tool, or you’ll scale the text, not its bounding box. 35 |

36 |
37 | 38 | 41 |

42 | Hold down the left mouse button and drag in the Comp window to create a paragraph text block. The edge—the text’s bounding box— is defined by how far you dragged the mouse when you created the paragraph text layer. This style of text wraps text to the next line when your type reaches the edge of the current line. 43 | 44 | You can resize the bounding box by clicking to place the cursor within the text, then dragging on one of the sizing handles around the perimeter of the bounding box. Shift-dragging a sizing handle will constrain the proportions of the bounding box. Make sure you don’t accidentally drag a sizing handle with the Selection tool, or you’ll scale the text, not its bounding box. 45 |

46 |
47 | 48 | -------------------------------------------------------------------------------- /public/examples/phase_diagram_description.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 21 | 22 | 23 | 24 |

25 | Hold down the left mouse button and drag in the Comp window to create a paragraph text block. The edge—the text’s bounding box— is defined by how far you dragged the mouse when you created the paragraph text layer. This style of text wraps text to the next line when your type reaches the edge of the current line. 26 | 27 | You can resize the bounding box by clicking to place the cursor within the text, then dragging on one of the sizing handles around the perimeter of the bounding box. Shift-dragging a sizing handle will constrain the proportions of the bounding box. Make sure you don’t accidentally drag a sizing handle with the Selection tool, or you’ll scale the text, not its bounding box. 28 |

29 | 30 |
31 |
32 |
33 |
34 | 37 |

38 | Hold down the left mouse button and drag in the Comp window to create a paragraph text block. The edge—the text’s bounding box— is defined by how far you dragged the mouse when you created the paragraph text layer. This style of text wraps text to the next line when your type reaches the edge of the current line. 39 | 40 | You can resize the bounding box by clicking to place the cursor within the text, then dragging on one of the sizing handles around the perimeter of the bounding box. Shift-dragging a sizing handle will constrain the proportions of the bounding box. Make sure you don’t accidentally drag a sizing handle with the Selection tool, or you’ll scale the text, not its bounding box. 41 |

42 |
43 | 44 | -------------------------------------------------------------------------------- /public/examples/poly_widget.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | -------------------------------------------------------------------------------- /public/examples/rnn.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 |
13 | 14 | 15 |
16 | 127 | 128 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /public/examples/sketch.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 |

22 | Each row is a single iterate down the left mouse button and drag in the Comp window to create a paragraph text block. The edge—the text’s bounding box— is defined by how far you dragged the mouse when you created the paragraph text layer. This style of text wraps text to the next line when your type reaches the edge of the current line. 23 |

24 |
25 | 26 |
27 | 28 | 29 | $$ \left(\begin{array}{c} 30 | y_{i}^{k}\\ 31 | x_{i}^{k} 32 | \end{array}\right)$$ 33 | 34 | 35 |
36 | The iterate is a sum of 37 |
38 | 39 | 40 | $$=$$ 41 | 42 | 43 | 44 | $$R^{k}\left(\begin{array}{c} 45 | y_{i}^{0}\\ 46 | x_{i}^{0} 47 | \end{array}\right)$$ 48 | 49 |
50 | the deterministic momentum iterates 51 |
52 | 53 | 54 | $$+$$ 55 | 56 | 57 | 58 | 59 | $$\epsilon^k_i \sum_{i=1}^{k}R^{k-i}\left(\begin{array}{c} 60 | 1\\ 61 | -\alpha 62 | \end{array}\right)$$ 63 | 64 | 65 |
66 | a decaying sum of the errors, where $\epsilon^k = Q \cdot \text{error}(w^k)$ 67 |
68 | 69 |
70 |
71 |

72 | Hold down the left mouse button and drag in the Comp window to create a paragraph text block. The edge—the text’s bounding box— is defined by how far you dragged the mouse when you created the paragraph text layer. This style of text wraps text to the next line when your type reaches the edge of the current line. 73 |

74 |
75 | 87 | 88 | -------------------------------------------------------------------------------- /public/thumbnail.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/distillpub/post--momentum/691048b9d00b4b49b830c602b970755781df332c/public/thumbnail.jpg -------------------------------------------------------------------------------- /yarn.lock: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | commander@2, commander@^2.9.0: 6 | version "2.9.0" 7 | resolved "https://registry.yarnpkg.com/commander/-/commander-2.9.0.tgz#9c99094176e12240cb22d6c5146098400fe0f7d4" 8 | dependencies: 9 | graceful-readlink ">= 1.0.0" 10 | 11 | d3-array@1, d3-array@1.1.1: 12 | version "1.1.1" 13 | resolved "https://registry.yarnpkg.com/d3-array/-/d3-array-1.1.1.tgz#a01abe63a25ffb91d3423c3c6d051b4d36bc8a09" 14 | 15 | d3-axis@1.0.6: 16 | version "1.0.6" 17 | resolved "https://registry.yarnpkg.com/d3-axis/-/d3-axis-1.0.6.tgz#dccbc21a73e5786de820bf1a22b237f522b878be" 18 | 19 | d3-brush@1.0.4: 20 | version "1.0.4" 21 | resolved "https://registry.yarnpkg.com/d3-brush/-/d3-brush-1.0.4.tgz#00c2f238019f24f6c0a194a26d41a1530ffe7bc4" 22 | dependencies: 23 | d3-dispatch "1" 24 | d3-drag "1" 25 | d3-interpolate "1" 26 | d3-selection "1" 27 | d3-transition "1" 28 | 29 | d3-chord@1.0.4: 30 | version "1.0.4" 31 | resolved "https://registry.yarnpkg.com/d3-chord/-/d3-chord-1.0.4.tgz#7dec4f0ba886f713fe111c45f763414f6f74ca2c" 32 | dependencies: 33 | d3-array "1" 34 | d3-path "1" 35 | 36 | d3-collection@1, d3-collection@1.0.3: 37 | version "1.0.3" 38 | resolved "https://registry.yarnpkg.com/d3-collection/-/d3-collection-1.0.3.tgz#00bdea94fbc1628d435abbae2f4dc2164e37dd34" 39 | 40 | d3-color@1, d3-color@1.0.3: 41 | version "1.0.3" 42 | resolved "https://registry.yarnpkg.com/d3-color/-/d3-color-1.0.3.tgz#bc7643fca8e53a8347e2fbdaffa236796b58509b" 43 | 44 | d3-dispatch@1, d3-dispatch@1.0.3: 45 | version "1.0.3" 46 | resolved "https://registry.yarnpkg.com/d3-dispatch/-/d3-dispatch-1.0.3.tgz#46e1491eaa9b58c358fce5be4e8bed626e7871f8" 47 | 48 | d3-drag@1, d3-drag@1.0.4: 49 | version "1.0.4" 50 | resolved "https://registry.yarnpkg.com/d3-drag/-/d3-drag-1.0.4.tgz#a9c1609f11dd5530ae275ebd64377ec54efb9d8f" 51 | dependencies: 52 | d3-dispatch "1" 53 | d3-selection "1" 54 | 55 | d3-dsv@1, d3-dsv@1.0.5: 56 | version "1.0.5" 57 | resolved "https://registry.yarnpkg.com/d3-dsv/-/d3-dsv-1.0.5.tgz#419f7db47f628789fc3fdb636e678449d0821136" 58 | dependencies: 59 | commander "2" 60 | iconv-lite "0.4" 61 | rw "1" 62 | 63 | d3-ease@1, d3-ease@1.0.3: 64 | version "1.0.3" 65 | resolved "https://registry.yarnpkg.com/d3-ease/-/d3-ease-1.0.3.tgz#68bfbc349338a380c44d8acc4fbc3304aa2d8c0e" 66 | 67 | d3-force@1.0.6: 68 | version "1.0.6" 69 | resolved "https://registry.yarnpkg.com/d3-force/-/d3-force-1.0.6.tgz#ea7e1b7730e2664cd314f594d6718c57cc132b79" 70 | dependencies: 71 | d3-collection "1" 72 | d3-dispatch "1" 73 | d3-quadtree "1" 74 | d3-timer "1" 75 | 76 | d3-format@1, d3-format@1.1.1: 77 | version "1.1.1" 78 | resolved "https://registry.yarnpkg.com/d3-format/-/d3-format-1.1.1.tgz#26e094e7b0fa925d3615aa6f43b265c5ca82b46e" 79 | 80 | d3-geo@1.6.3: 81 | version "1.6.3" 82 | resolved "https://registry.yarnpkg.com/d3-geo/-/d3-geo-1.6.3.tgz#21683a43a061eaba21a7f254b51d5937eb640756" 83 | dependencies: 84 | d3-array "1" 85 | 86 | d3-hierarchy@1.1.4: 87 | version "1.1.4" 88 | resolved "https://registry.yarnpkg.com/d3-hierarchy/-/d3-hierarchy-1.1.4.tgz#96c3942f3f21cf997a11b4edf00dde2a77b4c6d0" 89 | 90 | d3-interpolate@1, d3-interpolate@1.1.4: 91 | version "1.1.4" 92 | resolved "https://registry.yarnpkg.com/d3-interpolate/-/d3-interpolate-1.1.4.tgz#a43ec5b3bee350d8516efdf819a4c08c053db302" 93 | dependencies: 94 | d3-color "1" 95 | 96 | d3-path@1, d3-path@1.0.5: 97 | version "1.0.5" 98 | resolved "https://registry.yarnpkg.com/d3-path/-/d3-path-1.0.5.tgz#241eb1849bd9e9e8021c0d0a799f8a0e8e441764" 99 | 100 | d3-polygon@1.0.3: 101 | version "1.0.3" 102 | resolved "https://registry.yarnpkg.com/d3-polygon/-/d3-polygon-1.0.3.tgz#16888e9026460933f2b179652ad378224d382c62" 103 | 104 | d3-quadtree@1, d3-quadtree@1.0.3: 105 | version "1.0.3" 106 | resolved "https://registry.yarnpkg.com/d3-quadtree/-/d3-quadtree-1.0.3.tgz#ac7987e3e23fe805a990f28e1b50d38fcb822438" 107 | 108 | d3-queue@3.0.5: 109 | version "3.0.5" 110 | resolved "https://registry.yarnpkg.com/d3-queue/-/d3-queue-3.0.5.tgz#0ceffe1f131c459b13b9f69f1056b41dfc33c00d" 111 | 112 | d3-random@1.0.3: 113 | version "1.0.3" 114 | resolved "https://registry.yarnpkg.com/d3-random/-/d3-random-1.0.3.tgz#6526c844aa5e7c457e29ddacd6f2734f845b42c1" 115 | 116 | d3-request@1.0.5: 117 | version "1.0.5" 118 | resolved "https://registry.yarnpkg.com/d3-request/-/d3-request-1.0.5.tgz#4daae946d1dd0d57dfe01f022956354958d51f23" 119 | dependencies: 120 | d3-collection "1" 121 | d3-dispatch "1" 122 | d3-dsv "1" 123 | xmlhttprequest "1" 124 | 125 | d3-scale@1.0.5: 126 | version "1.0.5" 127 | resolved "https://registry.yarnpkg.com/d3-scale/-/d3-scale-1.0.5.tgz#418506f0fb18eb052b385e196398acc2a4134858" 128 | dependencies: 129 | d3-array "1" 130 | d3-collection "1" 131 | d3-color "1" 132 | d3-format "1" 133 | d3-interpolate "1" 134 | d3-time "1" 135 | d3-time-format "2" 136 | 137 | d3-selection@1, d3-selection@1.0.5: 138 | version "1.0.5" 139 | resolved "https://registry.yarnpkg.com/d3-selection/-/d3-selection-1.0.5.tgz#948c73b41a44e28d1742ae2ff207c2aebca2734b" 140 | 141 | d3-shape@1.0.6: 142 | version "1.0.6" 143 | resolved "https://registry.yarnpkg.com/d3-shape/-/d3-shape-1.0.6.tgz#b09e305cf0c7c6b9a98c90e6b42f62dac4bcfd5b" 144 | dependencies: 145 | d3-path "1" 146 | 147 | d3-swoopy-drag@^0.0.3: 148 | version "0.0.3" 149 | resolved "https://registry.yarnpkg.com/d3-swoopy-drag/-/d3-swoopy-drag-0.0.3.tgz#0a85b6ac1b8a3ba4bae4ecec9b96f7ac11b0fb2c" 150 | dependencies: 151 | d3 "4" 152 | 153 | d3-time-format@2, d3-time-format@2.0.5, d3-time-format@^2.0.3: 154 | version "2.0.5" 155 | resolved "https://registry.yarnpkg.com/d3-time-format/-/d3-time-format-2.0.5.tgz#9d7780204f7c9119c9170b1a56db4de9a8af972e" 156 | dependencies: 157 | d3-time "1" 158 | 159 | d3-time@1, d3-time@1.0.6: 160 | version "1.0.6" 161 | resolved "https://registry.yarnpkg.com/d3-time/-/d3-time-1.0.6.tgz#a55b13d7d15d3a160ae91708232e0835f1d5e945" 162 | 163 | d3-timer@1, d3-timer@1.0.5: 164 | version "1.0.5" 165 | resolved "https://registry.yarnpkg.com/d3-timer/-/d3-timer-1.0.5.tgz#b266d476c71b0d269e7ac5f352b410a3b6fe6ef0" 166 | 167 | d3-tip@^0.7.1: 168 | version "0.7.1" 169 | resolved "https://registry.yarnpkg.com/d3-tip/-/d3-tip-0.7.1.tgz#78cbf554f67b720a70e3b0f191e14cffe68cdd79" 170 | dependencies: 171 | d3 "^4.2" 172 | 173 | d3-transition@1, d3-transition@1.0.4: 174 | version "1.0.4" 175 | resolved "https://registry.yarnpkg.com/d3-transition/-/d3-transition-1.0.4.tgz#e1a9ebae3869a9d9c2874ab00841fa8313ae5de5" 176 | dependencies: 177 | d3-color "1" 178 | d3-dispatch "1" 179 | d3-ease "1" 180 | d3-interpolate "1" 181 | d3-selection "1" 182 | d3-timer "1" 183 | 184 | d3-voronoi@1.1.2: 185 | version "1.1.2" 186 | resolved "https://registry.yarnpkg.com/d3-voronoi/-/d3-voronoi-1.1.2.tgz#1687667e8f13a2d158c80c1480c5a29cb0d8973c" 187 | 188 | d3-zoom@1.1.3: 189 | version "1.1.3" 190 | resolved "https://registry.yarnpkg.com/d3-zoom/-/d3-zoom-1.1.3.tgz#0bd488622f22dc0534894f744a40ec979599fdc4" 191 | dependencies: 192 | d3-dispatch "1" 193 | d3-drag "1" 194 | d3-interpolate "1" 195 | d3-selection "1" 196 | d3-transition "1" 197 | 198 | d3@4, d3@^4.2, d3@^4.7.1: 199 | version "4.7.3" 200 | resolved "https://registry.yarnpkg.com/d3/-/d3-4.7.3.tgz#1bc7b0282b41d97642bdb673372c88e81ecca4a3" 201 | dependencies: 202 | d3-array "1.1.1" 203 | d3-axis "1.0.6" 204 | d3-brush "1.0.4" 205 | d3-chord "1.0.4" 206 | d3-collection "1.0.3" 207 | d3-color "1.0.3" 208 | d3-dispatch "1.0.3" 209 | d3-drag "1.0.4" 210 | d3-dsv "1.0.5" 211 | d3-ease "1.0.3" 212 | d3-force "1.0.6" 213 | d3-format "1.1.1" 214 | d3-geo "1.6.3" 215 | d3-hierarchy "1.1.4" 216 | d3-interpolate "1.1.4" 217 | d3-path "1.0.5" 218 | d3-polygon "1.0.3" 219 | d3-quadtree "1.0.3" 220 | d3-queue "3.0.5" 221 | d3-random "1.0.3" 222 | d3-request "1.0.5" 223 | d3-scale "1.0.5" 224 | d3-selection "1.0.5" 225 | d3-shape "1.0.6" 226 | d3-time "1.0.6" 227 | d3-time-format "2.0.5" 228 | d3-timer "1.0.5" 229 | d3-transition "1.0.4" 230 | d3-voronoi "1.1.2" 231 | d3-zoom "1.1.3" 232 | 233 | distill-template@^1.0.1: 234 | version "1.0.1" 235 | resolved "https://registry.yarnpkg.com/distill-template/-/distill-template-1.0.1.tgz#3e85cbf72b65bc4af59842ec4d40ca011c7a5bbb" 236 | dependencies: 237 | commander "^2.9.0" 238 | d3-time-format "^2.0.3" 239 | html-escape "^2.0.0" 240 | mustache "^2.3.0" 241 | 242 | "graceful-readlink@>= 1.0.0": 243 | version "1.0.1" 244 | resolved "https://registry.yarnpkg.com/graceful-readlink/-/graceful-readlink-1.0.1.tgz#4cafad76bc62f02fa039b2f94e9a3dd3a391a725" 245 | 246 | html-escape@^2.0.0: 247 | version "2.0.0" 248 | resolved "https://registry.yarnpkg.com/html-escape/-/html-escape-2.0.0.tgz#60c8ddd465edf0cae02af9e99fdf5f883b09be49" 249 | 250 | iconv-lite@0.4: 251 | version "0.4.15" 252 | resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.15.tgz#fe265a218ac6a57cfe854927e9d04c19825eddeb" 253 | 254 | mustache@^2.3.0: 255 | version "2.3.0" 256 | resolved "https://registry.yarnpkg.com/mustache/-/mustache-2.3.0.tgz#4028f7778b17708a489930a6e52ac3bca0da41d0" 257 | 258 | numeric@^1.2.6: 259 | version "1.2.6" 260 | resolved "https://registry.yarnpkg.com/numeric/-/numeric-1.2.6.tgz#765b02bef97988fcf880d4eb3f36b80fa31335aa" 261 | 262 | rw@1: 263 | version "1.3.3" 264 | resolved "https://registry.yarnpkg.com/rw/-/rw-1.3.3.tgz#3f862dfa91ab766b14885ef4d01124bfda074fb4" 265 | 266 | xmlhttprequest@1: 267 | version "1.8.0" 268 | resolved "https://registry.yarnpkg.com/xmlhttprequest/-/xmlhttprequest-1.8.0.tgz#67fe075c5c24fef39f9d65f5f7b7fe75171968fc" 269 | --------------------------------------------------------------------------------