This commit is contained in:
Morten Hjorth-Jensen
2024-10-08 17:04:26 +02:00
parent 87d1e4455c
commit dbbebedb06
114 changed files with 3736 additions and 1751 deletions
+112 -112
View File
@@ -794,15 +794,15 @@ regression.</p>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Own inversion
[[4.0846409]
[2.8352834]]
Eigenvalues of Hessian Matrix:[0.33241952 4.39292847]
[[3.96581896]
[3.03624103]]
Eigenvalues of Hessian Matrix:[0.26120167 4.71129677]
theta from own gd
[[4.0846409]
[2.8352834]]
[[3.96581896]
[3.03624103]]
theta from own sdg
[[4.03188133]
[2.82130663]]
[[3.99729015]
[3.02646648]]
</pre></div>
</div>
<img alt="_images/exercisesweek41_5_1.png" src="_images/exercisesweek41_5_1.png" />
@@ -924,14 +924,14 @@ first example shows results with ordinary leats squares.</p>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Own inversion
[[3.89543945]
[3.14433067]]
Eigenvalues of Hessian Matrix:[0.30069427 4.55916434]
[[4.03656288]
[2.95497813]]
Eigenvalues of Hessian Matrix:[0.29560433 4.58257727]
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>theta from own gd
[[3.89543945]
[3.14433067]]
[[4.03656288]
[2.95497813]]
</pre></div>
</div>
<img alt="_images/exercisesweek41_16_2.png" src="_images/exercisesweek41_16_2.png" />
@@ -1002,73 +1002,73 @@ Eigenvalues of Hessian Matrix:[0.30069427 4.55916434]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Own inversion
[[4.]
[3.]]
Eigenvalues of Hessian Matrix:[0.30043041 4.28093636]
0 [-13.544421] [-15.11052859]
1 [-0.26692247] [0.23040825]
2 [-0.2481902] [0.2142385]
3 [-0.23077255] [0.19920353]
4 [-0.21457724] [0.18522369]
5 [-0.19951849] [0.17222494]
6 [-0.18551655] [0.16013842]
7 [-0.17249725] [0.14890012]
8 [-0.16039162] [0.13845051]
9 [-0.14913555] [0.12873424]
10 [-0.13866942] [0.11969984]
11 [-0.12893778] [0.11129947]
12 [-0.1198891] [0.10348862]
13 [-0.11147544] [0.09622593]
14 [-0.10365224] [0.08947292]
15 [-0.09637807] [0.08319383]
16 [-0.08961438] [0.0773554]
17 [-0.08332537] [0.0719267]
18 [-0.0774777] [0.06687898]
19 [-0.07204042] [0.0621855]
20 [-0.06698472] [0.0578214]
21 [-0.06228382] [0.05376358]
22 [-0.05791283] [0.04999052]
23 [-0.05384858] [0.04648225]
24 [-0.05006956] [0.04322019]
25 [-0.04655574] [0.04018705]
26 [-0.04328852] [0.03736678]
27 [-0.04025059] [0.03474443]
28 [-0.03742586] [0.03230611]
29 [-0.03479936] [0.03003891]
Eigenvalues of Hessian Matrix:[0.27750534 4.13217667]
0 [-10.24816468] [-11.05638246]
1 [-0.1602625] [0.14404536]
2 [-0.14949972] [0.13437168]
3 [-0.13945974] [0.12534765]
4 [-0.13009402] [0.11692966]
5 [-0.12135727] [0.10907699]
6 [-0.11320726] [0.10175169]
7 [-0.10560458] [0.09491833]
8 [-0.09851247] [0.08854388]
9 [-0.09189665] [0.08259753]
10 [-0.08572513] [0.07705051]
11 [-0.07996807] [0.07187601]
12 [-0.07459764] [0.06704902]
13 [-0.06958788] [0.0625462]
14 [-0.06491455] [0.05834577]
15 [-0.06055507] [0.05442743]
16 [-0.05648836] [0.05077224]
17 [-0.05269476] [0.04736252]
18 [-0.04915593] [0.04418179]
19 [-0.04585476] [0.04121466]
20 [-0.04277528] [0.0384468]
21 [-0.03990261] [0.03586482]
22 [-0.03722287] [0.03345624]
23 [-0.03472308] [0.03120942]
24 [-0.03239118] [0.02911348]
25 [-0.03021588] [0.0271583]
26 [-0.02818667] [0.02533443]
27 [-0.02629373] [0.02363304]
28 [-0.02452792] [0.02204591]
29 [-0.02288069] [0.02056537]
theta from own gd
[[3.89229722]
[3.09296935]]
0 [-0.03235719] [0.02793082]
1 [-0.03008641] [0.02597067]
2 [-0.02729375] [0.02356004]
3 [-0.02454051] [0.02118344]
4 [-0.02199232] [0.01898383]
5 [-0.01968447] [0.01699169]
6 [-0.01761069] [0.01520159]
7 [-0.01575266] [0.01359774]
8 [-0.01408975] [0.01216231]
9 [-0.01260207] [0.01087815]
10 [-0.01127138] [0.00972948]
11 [-0.01008116] [0.00870208]
12 [-0.00901661] [0.00778316]
13 [-0.00806447] [0.00696127]
14 [-0.00721287] [0.00622617]
15 [-0.00645121] [0.0055687]
16 [-0.00576997] [0.00498065]
17 [-0.00516067] [0.0044547]
18 [-0.00461571] [0.00398429]
19 [-0.0041283] [0.00356356]
20 [-0.00369236] [0.00318725]
21 [-0.00330245] [0.00285068]
22 [-0.00295372] [0.00254966]
23 [-0.00264181] [0.00228042]
24 [-0.00236284] [0.00203961]
25 [-0.00211332] [0.00182423]
26 [-0.00189016] [0.00163159]
27 [-0.00169056] [0.0014593]
28 [-0.00151204] [0.0013052]
29 [-0.00135237] [0.00116737]
[[3.92308585]
[3.06913112]]
0 [-0.02134409] [0.01918426]
1 [-0.01991068] [0.01789589]
2 [-0.01814351] [0.01630755]
3 [-0.01639489] [0.01473588]
4 [-0.01476927] [0.01327475]
5 [-0.01328972] [0.01194492]
6 [-0.01195336] [0.01074379]
7 [-0.0107497] [0.00966192]
8 [-0.00966668] [0.0086885]
9 [-0.00869259] [0.00781297]
10 [-0.00781659] [0.00702562]
11 [-0.00702885] [0.00631759]
12 [-0.00632049] [0.00568091]
13 [-0.00568352] [0.00510839]
14 [-0.00511073] [0.00459357]
15 [-0.00459568] [0.00413064]
16 [-0.00413253] [0.00371435]
17 [-0.00371605] [0.00334002]
18 [-0.00334155] [0.00300342]
19 [-0.00300479] [0.00270073]
20 [-0.00270197] [0.00242856]
21 [-0.00242967] [0.00218381]
22 [-0.00218481] [0.00196372]
23 [-0.00196462] [0.00176582]
24 [-0.00176663] [0.00158786]
25 [-0.00158859] [0.00142784]
26 [-0.00142849] [0.00128394]
27 [-0.00128453] [0.00115455]
28 [-0.00115508] [0.00103819]
29 [-0.00103867] [0.00093356]
theta from own gd wth momentum
[[3.9959739 ]
[3.00347534]]
[[3.99663433]
[3.00302509]]
</pre></div>
</div>
</div>
@@ -1121,17 +1121,17 @@ theta from own gd wth momentum
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Own inversion
[[3.96414331]
[3.22481166]]
Eigenvalues of Hessian Matrix:[0.26674792 4.38123077]
0 [-15.60151468] [-17.64192473]
1 [-1.66342634e-14] [-1.21941484e-14]
2 [-6.41847686e-17] [1.63371136e-16]
3 [-6.76542156e-17] [-4.78340902e-17]
4 [-6.76542156e-17] [-4.78340902e-17]
[[3.81924504]
[3.09224244]]
Eigenvalues of Hessian Matrix:[0.31096156 4.57735536]
0 [-15.77829399] [-18.53684024]
1 [-3.15242624e-15] [-1.65243388e-16]
2 [3.85975973e-17] [5.35468713e-17]
3 [3.85975973e-17] [5.35468713e-17]
4 [3.85975973e-17] [5.35468713e-17]
beta from own Newton code
[[3.96414331]
[3.22481166]]
[[3.81924504]
[3.09224244]]
</pre></div>
</div>
</div>
@@ -1220,20 +1220,20 @@ beta from own Newton code
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Own inversion
[[3.84668873]
[3.21776599]]
Eigenvalues of Hessian Matrix:[0.28766899 4.2084894 ]
[[3.84019294]
[3.22756518]]
Eigenvalues of Hessian Matrix:[0.2729933 4.56108455]
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>theta from own gd
[[3.84668873]
[3.21776599]]
[[3.84019294]
[3.22756518]]
</pre></div>
</div>
<img alt="_images/exercisesweek41_22_2.png" src="_images/exercisesweek41_22_2.png" />
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>theta from own sdg
[[3.86757762]
[3.17214797]]
[[3.85298956]
[3.28358004]]
</pre></div>
</div>
</div>
@@ -1315,15 +1315,15 @@ Eigenvalues of Hessian Matrix:[0.28766899 4.2084894 ]
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Own inversion
[[3.90140097]
[3.0552878 ]]
Eigenvalues of Hessian Matrix:[0.32683063 4.01722503]
[[4.1356995 ]
[3.09209032]]
Eigenvalues of Hessian Matrix:[0.31362428 4.21949761]
theta from own gd
[[3.90137221]
[3.055314 ]]
[[4.13531906]
[3.09242193]]
theta from own sdg with momentum
[[3.83824223]
[3.10556487]]
[[4.25003261]
[3.05169046]]
</pre></div>
</div>
</div>
@@ -1398,9 +1398,9 @@ theta from own sdg with momentum
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>theta from own AdaGrad
[[2.00003645]
[2.99977853]
[4.00021916]]
[[2.00006114]
[2.99959609]
[4.00040218]]
</pre></div>
</div>
</div>
@@ -1482,9 +1482,9 @@ theta from own sdg with momentum
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>theta from own RMSprop
[[1.99985591]
[3.00049636]
[3.99943837]]
[[1.99952851]
[3.00380258]
[3.995522 ]]
</pre></div>
</div>
</div>
@@ -1570,9 +1570,9 @@ theta from own sdg with momentum
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>theta from own ADAM
[[2.00008335]
[2.99969576]
[4.00033679]]
[[1.99984836]
[3.00097416]
[3.99895448]]
</pre></div>
</div>
</div>
@@ -1645,7 +1645,7 @@ It provides composable transformations of Python+NumPy programs: differentiate,
return asarray(x, dtype=self.dtype)
</pre></div>
</div>
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[&lt;matplotlib.lines.Line2D at 0x126431130&gt;]
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[&lt;matplotlib.lines.Line2D at 0x145270160&gt;]
</pre></div>
</div>
<img alt="_images/exercisesweek41_39_2.png" src="_images/exercisesweek41_39_2.png" />
@@ -1680,7 +1680,7 @@ It provides composable transformations of Python+NumPy programs: differentiate,
</div>
</div>
<div class="cell_output docutils container">
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&lt;matplotlib.collections.PathCollection at 0x117edb760&gt;
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&lt;matplotlib.collections.PathCollection at 0x1452d6eb0&gt;
</pre></div>
</div>
<img alt="_images/exercisesweek41_41_1.png" src="_images/exercisesweek41_41_1.png" />