This commit is contained in:
Morten Hjorth-Jensen
2023-10-15 21:55:49 +02:00
parent cb5ab447ad
commit edf33b439c
171 changed files with 18722 additions and 1691 deletions
+127 -112
View File
@@ -323,6 +323,16 @@ const thebe_selector_output = ".output, .cell_output"
Week 41 Neural networks and constructing a neural network code
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek42.html">
Exercises week 42
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="week42.html">
Week 42 Constructing a Neural Network code with introduction to Tensor flow
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -335,6 +345,11 @@ const thebe_selector_output = ".output, .cell_output"
Project 1 on Machine Learning, deadline October 9 (midnight), 2023
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="project2.html">
Project 2 on Machine Learning, deadline November 13 (Midnight)
</a>
</li>
</ul>
</div>
@@ -789,15 +804,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.83505053]
[3.09726322]]
Eigenvalues of Hessian Matrix:[0.27717261 4.34154132]
[[3.89481038]
[3.13155259]]
Eigenvalues of Hessian Matrix:[0.28194659 4.81122914]
theta from own gd
[[3.83505053]
[3.09726322]]
[[3.89481038]
[3.13155259]]
theta from own sdg
[[3.77589027]
[3.07286416]]
[[3.88291866]
[3.19123037]]
</pre></div>
</div>
<img alt="_images/exercisesweek41_5_1.png" src="_images/exercisesweek41_5_1.png" />
@@ -919,14 +934,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.81651921]
[3.10399758]]
Eigenvalues of Hessian Matrix:[0.30971881 4.52950417]
[[4.23636536]
[2.77184871]]
Eigenvalues of Hessian Matrix:[0.30125775 4.66878535]
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>theta from own gd
[[3.81651921]
[3.10399758]]
[[4.23636536]
[2.77184871]]
</pre></div>
</div>
<img alt="_images/exercisesweek41_16_2.png" src="_images/exercisesweek41_16_2.png" />
@@ -997,73 +1012,73 @@ Eigenvalues of Hessian Matrix:[0.30971881 4.52950417]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Own inversion
[[4.]
[3.]]
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]
Eigenvalues of Hessian Matrix:[0.35058127 4.29679459]
0 [-8.31895514] [-8.15055258]
1 [-0.75472506] [0.63957747]
2 [-0.69314603] [0.58739348]
3 [-0.63659131] [0.53946725]
4 [-0.58465096] [0.49545139]
5 [-0.5369485] [0.45502684]
6 [-0.49313815] [0.41790059]
7 [-0.45290234] [0.38380352]
8 [-0.41594943] [0.35248847]
9 [-0.38201155] [0.32372846]
10 [-0.35084272] [0.29731502]
11 [-0.32221699] [0.27305669]
12 [-0.29592687] [0.25077762]
13 [-0.2717818] [0.23031634]
14 [-0.24960675] [0.21152452]
15 [-0.229241] [0.19426595]
16 [-0.21053692] [0.17841553]
17 [-0.19335893] [0.16385836]
18 [-0.17758251] [0.15048894]
19 [-0.16309331] [0.13821034]
20 [-0.14978631] [0.12693357]
21 [-0.13756504] [0.11657689]
22 [-0.12634093] [0.10706523]
23 [-0.1160326] [0.09832963]
24 [-0.10656534] [0.09030678]
25 [-0.09787053] [0.08293853]
26 [-0.08988514] [0.07617146]
27 [-0.08255129] [0.06995653]
28 [-0.07581582] [0.06424868]
29 [-0.06962991] [0.05900655]
theta from own gd
[[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]
[[3.81759234]
[3.15457792]]
0 [-0.06394871] [0.05419212]
1 [-0.05873105] [0.04977051]
2 [-0.0523738] [0.04438319]
3 [-0.04619338] [0.03914571]
4 [-0.04057027] [0.03438051]
5 [-0.03557316] [0.0301458]
6 [-0.03117156] [0.02641575]
7 [-0.02730775] [0.02314144]
8 [-0.02392053] [0.020271]
9 [-0.02095266] [0.01775594]
10 [-0.01835274] [0.01555268]
11 [-0.01607534] [0.01362274]
12 [-0.01408051] [0.01193226]
13 [-0.01233322] [0.01045155]
14 [-0.01080274] [0.00915458]
15 [-0.00946219] [0.00801855]
16 [-0.00828799] [0.0070235]
17 [-0.0072595] [0.00615193]
18 [-0.00635865] [0.00538851]
19 [-0.00556958] [0.00471983]
20 [-0.00487843] [0.00413413]
21 [-0.00427304] [0.00362111]
22 [-0.00374279] [0.00317175]
23 [-0.00327833] [0.00277816]
24 [-0.00287151] [0.00243341]
25 [-0.00251517] [0.00213144]
26 [-0.00220306] [0.00186694]
27 [-0.00192967] [0.00163526]
28 [-0.00169021] [0.00143234]
29 [-0.00148047] [0.00125459]
theta from own gd wth momentum
[[3.9993736 ]
[3.00053008]]
[[3.99630114]
[3.00313452]]
</pre></div>
</div>
</div>
@@ -1116,17 +1131,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.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]
[[4.08185019]
[2.82781715]]
Eigenvalues of Hessian Matrix:[0.32244056 3.90871918]
0 [-14.19393543] [-14.29174301]
1 [-6.35255737e-15] [-1.10851799e-14]
2 [-5.89805982e-17] [-2.66490332e-16]
3 [9.81853487e-16] [1.10741066e-15]
4 [-5.89805982e-17] [-2.66490332e-16]
beta from own Newton code
[[3.92351924]
[3.025027 ]]
[[4.08185019]
[2.82781715]]
</pre></div>
</div>
</div>
@@ -1215,20 +1230,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
[[4.08928088]
[2.79578306]]
Eigenvalues of Hessian Matrix:[0.31588332 4.45642521]
[[3.41716708]
[3.50046106]]
Eigenvalues of Hessian Matrix:[0.24252405 4.30774404]
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>theta from own gd
[[4.08928088]
[2.79578306]]
[[3.41716708]
[3.50046106]]
</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
[[4.10188623]
[2.87242312]]
[[3.38135654]
[3.49216685]]
</pre></div>
</div>
</div>
@@ -1310,15 +1325,15 @@ Eigenvalues of Hessian Matrix:[0.31588332 4.45642521]
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Own inversion
[[3.84094234]
[3.01300561]]
Eigenvalues of Hessian Matrix:[0.26776828 4.97262227]
[[4.12427537]
[2.85355539]]
Eigenvalues of Hessian Matrix:[0.33486875 3.91080327]
theta from own gd
[[3.83774539]
[3.01544605]]
[[4.12417157]
[2.85365229]]
theta from own sdg with momentum
[[3.8186717 ]
[3.06511966]]
[[4.25050227]
[2.8249367 ]]
</pre></div>
</div>
</div>
@@ -1393,9 +1408,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.00019432]
[2.99888222]
[4.00105497]]
[[1.99999773]
[3.0000164 ]
[3.99998703]]
</pre></div>
</div>
</div>
@@ -1477,9 +1492,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.9996357 ]
[3.00788598]
[3.99589367]]
[[2.01023308]
[2.95235306]
[4.04597076]]
</pre></div>
</div>
</div>
@@ -1565,9 +1580,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.0001042 ]
[2.99949077]
[4.00048049]]
[[1.99998193]
[3.0000747 ]
[3.99992263]]
</pre></div>
</div>
</div>
@@ -1640,7 +1655,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 0x1268ba940&gt;]
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[&lt;matplotlib.lines.Line2D at 0x10febc640&gt;]
</pre></div>
</div>
<img alt="_images/exercisesweek41_39_2.png" src="_images/exercisesweek41_39_2.png" />
@@ -1679,7 +1694,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 0x1162c32b0&gt;
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&lt;matplotlib.collections.PathCollection at 0x10febcf10&gt;
</pre></div>
</div>
<img alt="_images/exercisesweek41_41_2.png" src="_images/exercisesweek41_41_2.png" />