small corrections

This commit is contained in:
Morten Hjorth-Jensen
2023-10-10 11:27:55 +02:00
parent e442964ea8
commit 0467d80faa
18 changed files with 2575 additions and 357 deletions
+116 -114
View File
@@ -789,15 +789,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
[[3.97594511]
[2.99866581]]
Eigenvalues of Hessian Matrix:[0.39890447 3.73456649]
[[3.83505053]
[3.09726322]]
Eigenvalues of Hessian Matrix:[0.27717261 4.34154132]
theta from own gd
[[3.97594511]
[2.99866581]]
[[3.83505053]
[3.09726322]]
theta from own sdg
[[3.94814932]
[2.97879245]]
[[3.77589027]
[3.07286416]]
</pre></div>
</div>
<img alt="_images/exercisesweek41_5_1.png" src="_images/exercisesweek41_5_1.png" />
@@ -919,14 +919,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
[[4.09527217]
[3.02622906]]
Eigenvalues of Hessian Matrix:[0.34998197 4.32265589]
[[3.81651921]
[3.10399758]]
Eigenvalues of Hessian Matrix:[0.30971881 4.52950417]
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>theta from own gd
[[4.09527217]
[3.02622906]]
[[3.81651921]
[3.10399758]]
</pre></div>
</div>
<img alt="_images/exercisesweek41_16_2.png" src="_images/exercisesweek41_16_2.png" />
@@ -997,73 +997,73 @@ Eigenvalues of Hessian Matrix:[0.34998197 4.32265589]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Own inversion
[[4.]
[3.]]
Eigenvalues of Hessian Matrix:[0.28837459 4.42584543]
0 [-15.52856208] [-17.65196615]
1 [-0.3842967] [0.3228044]
2 [-0.3592571] [0.30177145]
3 [-0.335849] [0.28210895]
4 [-0.3139661] [0.26372759]
5 [-0.29350903] [0.2465439]
6 [-0.27438488] [0.23047985]
7 [-0.25650679] [0.21546249]
8 [-0.23979359] [0.20142361]
9 [-0.22416937] [0.18829946]
10 [-0.20956318] [0.17603044]
11 [-0.19590868] [0.16456084]
12 [-0.18314387] [0.15383855]
13 [-0.17121077] [0.1438149]
14 [-0.1600552] [0.13444436]
15 [-0.14962649] [0.12568438]
16 [-0.13987729] [0.11749517]
17 [-0.13076331] [0.10983954]
18 [-0.12224317] [0.10268273]
19 [-0.11427818] [0.09599224]
20 [-0.10683216] [0.08973767]
21 [-0.0998713] [0.08389064]
22 [-0.09336399] [0.07842458]
23 [-0.08728068] [0.07331468]
24 [-0.08159374] [0.06853772]
25 [-0.07627734] [0.06407201]
26 [-0.07130734] [0.05989727]
27 [-0.06666117] [0.05599455]
28 [-0.06231773] [0.05234611]
29 [-0.0582573] [0.0489354]
Eigenvalues of Hessian Matrix:[0.28641189 4.39287528]
0 [-15.65565751] [-18.44347438]
1 [-0.02618169] [0.02215597]
2 [-0.02447466] [0.02071142]
3 [-0.02287894] [0.01936105]
4 [-0.02138725] [0.01809873]
5 [-0.01999282] [0.01691871]
6 [-0.0186893] [0.01581562]
7 [-0.01747077] [0.01478446]
8 [-0.01633169] [0.01382052]
9 [-0.01526688] [0.01291943]
10 [-0.01427149] [0.0120771]
11 [-0.013341] [0.01128968]
12 [-0.01247118] [0.0105536]
13 [-0.01165807] [0.00986552]
14 [-0.01089797] [0.00922229]
15 [-0.01018743] [0.00862101]
16 [-0.00952322] [0.00805892]
17 [-0.00890232] [0.00753349]
18 [-0.00832189] [0.00704231]
19 [-0.00777931] [0.00658316]
20 [-0.00727211] [0.00615394]
21 [-0.00679797] [0.00575271]
22 [-0.00635475] [0.00537764]
23 [-0.00594042] [0.00502702]
24 [-0.00555311] [0.00469926]
25 [-0.00519105] [0.00439287]
26 [-0.0048526] [0.00410646]
27 [-0.00453622] [0.00383872]
28 [-0.00424046] [0.00358844]
29 [-0.00396398] [0.00335448]
theta from own gd
[[3.81114345]
[3.15863713]]
0 [-0.05446143] [0.04574692]
1 [-0.05091289] [0.04276619]
2 [-0.046531] [0.03908546]
3 [-0.04218461] [0.03543455]
4 [-0.03813208] [0.03203047]
5 [-0.03443175] [0.02892224]
6 [-0.03107818] [0.02610528]
7 [-0.02804715] [0.02355925]
8 [-0.02531037] [0.0212604]
9 [-0.02284019] [0.01918548]
10 [-0.02061094] [0.01731293]
11 [-0.01859922] [0.01562311]
12 [-0.01678384] [0.01409821]
13 [-0.01514564] [0.01272215]
14 [-0.01366733] [0.01148039]
15 [-0.01233332] [0.01035984]
16 [-0.01112952] [0.00934865]
17 [-0.01004321] [0.00843617]
18 [-0.00906293] [0.00761275]
19 [-0.00817834] [0.0068697]
20 [-0.00738008] [0.00619918]
21 [-0.00665974] [0.0055941]
22 [-0.00600971] [0.00504808]
23 [-0.00542313] [0.00455536]
24 [-0.0048938] [0.00411073]
25 [-0.00441613] [0.0037095]
26 [-0.00398509] [0.00334743]
27 [-0.00359612] [0.0030207]
28 [-0.00324512] [0.00272586]
29 [-0.00292838] [0.0024598]
[[3.98706221]
[3.01094846]]
0 [-0.00370554] [0.00313577]
1 [-0.00346394] [0.00293132]
2 [-0.00316561] [0.00267887]
3 [-0.00286972] [0.00242847]
4 [-0.00259385] [0.00219502]
5 [-0.00234197] [0.00198187]
6 [-0.00211371] [0.00178871]
7 [-0.00190742] [0.00161414]
8 [-0.00172117] [0.00145652]
9 [-0.00155308] [0.00131428]
10 [-0.00140139] [0.00118591]
11 [-0.00126452] [0.00107008]
12 [-0.00114101] [0.00096557]
13 [-0.00102956] [0.00087126]
14 [-0.000929] [0.00078616]
15 [-0.00083826] [0.00070937]
16 [-0.00075639] [0.00064009]
17 [-0.00068251] [0.00057757]
18 [-0.00061585] [0.00052115]
19 [-0.0005557] [0.00047025]
20 [-0.00050142] [0.00042432]
21 [-0.00045244] [0.00038288]
22 [-0.00040825] [0.00034548]
23 [-0.00036838] [0.00031174]
24 [-0.0003324] [0.00028129]
25 [-0.00029993] [0.00025381]
26 [-0.00027064] [0.00022902]
27 [-0.0002442] [0.00020665]
28 [-0.00022035] [0.00018647]
29 [-0.00019883] [0.00016826]
theta from own gd wth momentum
[[3.99083639]
[3.00769731]]
[[3.9993736 ]
[3.00053008]]
</pre></div>
</div>
</div>
@@ -1116,17 +1116,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.83190841]
[2.9998542 ]]
Eigenvalues of Hessian Matrix:[0.27971414 4.455592 ]
0 [-12.5786304] [-15.41021561]
1 [-2.79550688e-15] [-2.24968001e-16]
2 [-2.2941718e-16] [-4.20820528e-16]
3 [4.95697233e-16] [5.72742343e-16]
4 [4.95697233e-16] [5.72742343e-16]
[[3.92351924]
[3.025027 ]]
Eigenvalues of Hessian Matrix:[0.33104875 3.95055425]
0 [-11.75315452] [-11.48461009]
1 [3.84783351e-15] [-1.7484672e-15]
2 [-4.8897518e-16] [-4.48356153e-16]
3 [4.61653285e-16] [3.79106945e-16]
4 [-4.8897518e-16] [-4.48356153e-16]
beta from own Newton code
[[3.83190841]
[2.9998542 ]]
[[3.92351924]
[3.025027 ]]
</pre></div>
</div>
</div>
@@ -1215,18 +1215,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.93988393]
[3.06578047]]
Eigenvalues of Hessian Matrix:[0.34100913 4.27547557]
theta from own gd
[[3.93988393]
[3.06578047]]
[[4.08928088]
[2.79578306]]
Eigenvalues of Hessian Matrix:[0.31588332 4.45642521]
</pre></div>
</div>
<img alt="_images/exercisesweek41_22_1.png" src="_images/exercisesweek41_22_1.png" />
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>theta from own gd
[[4.08928088]
[2.79578306]]
</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.92648983]
[3.07020234]]
[[4.10188623]
[2.87242312]]
</pre></div>
</div>
</div>
@@ -1308,15 +1310,15 @@ theta from own gd
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Own inversion
[[4.12998822]
[2.78886274]]
Eigenvalues of Hessian Matrix:[0.3303366 4.33020191]
[[3.84094234]
[3.01300561]]
Eigenvalues of Hessian Matrix:[0.26776828 4.97262227]
theta from own gd
[[4.12921833]
[2.78951443]]
[[3.83774539]
[3.01544605]]
theta from own sdg with momentum
[[4.10156593]
[2.7748567 ]]
[[3.8186717 ]
[3.06511966]]
</pre></div>
</div>
</div>
@@ -1391,9 +1393,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
[[1.9978254 ]
[3.01066976]
[3.98914003]]
[[2.00019432]
[2.99888222]
[4.00105497]]
</pre></div>
</div>
</div>
@@ -1475,9 +1477,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.99984215]
[2.99767262]
[3.99944037]]
[[1.9996357 ]
[3.00788598]
[3.99589367]]
</pre></div>
</div>
</div>
@@ -1563,9 +1565,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
[[1.99988325]
[3.00072412]
[3.99932732]]
[[2.0001042 ]
[2.99949077]
[4.00048049]]
</pre></div>
</div>
</div>
@@ -1638,7 +1640,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 0x11df37280&gt;]
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[&lt;matplotlib.lines.Line2D at 0x1268ba940&gt;]
</pre></div>
</div>
<img alt="_images/exercisesweek41_39_2.png" src="_images/exercisesweek41_39_2.png" />
@@ -1677,7 +1679,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.collections.PathCollection at 0x11de12520&gt;
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&lt;matplotlib.collections.PathCollection at 0x1162c32b0&gt;
</pre></div>
</div>
<img alt="_images/exercisesweek41_41_2.png" src="_images/exercisesweek41_41_2.png" />