This commit is contained in:
Morten Hjorth-Jensen
2024-10-21 13:45:48 +02:00
parent 0a03ba583c
commit de6a6d8bcb
144 changed files with 7186 additions and 4274 deletions
+121 -114
View File
@@ -343,6 +343,11 @@ const thebe_selector_output = ".output, .cell_output"
Week 43: Deep Learning: Constructing a Neural Network code and solving differential equations
</a>
</li>
<li class="toctree-l1">
<a class="reference internal" href="exercisesweek43.html">
Exercises week 43
</a>
</li>
</ul>
<p aria-level="2" class="caption" role="heading">
<span class="caption-text">
@@ -814,15 +819,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.2561719 ]
[2.65632442]]
Eigenvalues of Hessian Matrix:[0.33282365 4.37023448]
[[4.15515965]
[2.99763835]]
Eigenvalues of Hessian Matrix:[0.3156062 4.19886862]
theta from own gd
[[4.2561719 ]
[2.65632442]]
[[4.15515965]
[2.99763835]]
theta from own sdg
[[4.25767462]
[2.65759127]]
[[4.18290649]
[2.96486591]]
</pre></div>
</div>
<img alt="_images/exercisesweek41_5_1.png" src="_images/exercisesweek41_5_1.png" />
@@ -944,12 +949,12 @@ 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.96801916]
[2.95289375]]
Eigenvalues of Hessian Matrix:[0.27223854 4.51713064]
[[3.98635543]
[2.9642492 ]]
Eigenvalues of Hessian Matrix:[0.31545424 4.4234122 ]
theta from own gd
[[3.96801916]
[2.95289375]]
[[3.98635543]
[2.9642492 ]]
</pre></div>
</div>
<img alt="_images/exercisesweek41_16_1.png" src="_images/exercisesweek41_16_1.png" />
@@ -1020,73 +1025,73 @@ theta from own gd
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Own inversion
[[4.]
[3.]]
Eigenvalues of Hessian Matrix:[0.29155617 4.71527295]
0 [-13.19526866] [-16.48597324]
1 [-0.06810332] [0.05402091]
2 [-0.06389233] [0.05068067]
3 [-0.05994172] [0.04754697]
4 [-0.05623539] [0.04460703]
5 [-0.05275823] [0.04184888]
6 [-0.04949606] [0.03926126]
7 [-0.04643561] [0.03683365]
8 [-0.04356439] [0.03455614]
9 [-0.0408707] [0.03241945]
10 [-0.03834357] [0.03041488]
11 [-0.0359727] [0.02853426]
12 [-0.03374843] [0.02676992]
13 [-0.03166168] [0.02511468]
14 [-0.02970397] [0.02356178]
15 [-0.0278673] [0.0221049]
16 [-0.0261442] [0.0207381]
17 [-0.02452765] [0.01945582]
18 [-0.02301105] [0.01825282]
19 [-0.02158822] [0.01712421]
20 [-0.02025337] [0.01606538]
21 [-0.01900106] [0.01507202]
22 [-0.01782618] [0.01414008]
23 [-0.01672395] [0.01326577]
24 [-0.01568987] [0.01244551]
25 [-0.01471973] [0.01167598]
26 [-0.01380957] [0.01095403]
27 [-0.01295569] [0.01027671]
28 [-0.01215461] [0.00964128]
29 [-0.01140307] [0.00904514]
Eigenvalues of Hessian Matrix:[0.35350927 4.2330123 ]
0 [-10.02028415] [-11.38281882]
1 [-0.12978318] [0.11144292]
2 [-0.11894467] [0.10213605]
3 [-0.10901131] [0.09360642]
4 [-0.0999075] [0.08578912]
5 [-0.09156398] [0.07862466]
6 [-0.08391725] [0.07205852]
7 [-0.07690911] [0.06604073]
8 [-0.07048624] [0.06052551]
9 [-0.06459976] [0.05547088]
10 [-0.05920488] [0.05083837]
11 [-0.05426053] [0.04659273]
12 [-0.0497291] [0.04270166]
13 [-0.0455761] [0.03913554]
14 [-0.04176993] [0.03586723]
15 [-0.03828162] [0.03287187]
16 [-0.03508463] [0.03012666]
17 [-0.03215463] [0.02761071]
18 [-0.02946931] [0.02530487]
19 [-0.02700826] [0.0231916]
20 [-0.02475273] [0.02125481]
21 [-0.02268557] [0.01947977]
22 [-0.02079104] [0.01785297]
23 [-0.01905473] [0.01636202]
24 [-0.01746342] [0.01499559]
25 [-0.01600501] [0.01374327]
26 [-0.01466839] [0.01259554]
27 [-0.0134434] [0.01154365]
28 [-0.01232071] [0.01057961]
29 [-0.01129178] [0.00969608]
theta from own gd
[[3.96330728]
[3.02910539]]
0 [-0.01069799] [0.00848586]
1 [-0.01003651] [0.00796116]
2 [-0.00921748] [0.00731149]
3 [-0.00840184] [0.0066645]
4 [-0.00763764] [0.00605833]
5 [-0.00693613] [0.00550187]
6 [-0.0062968] [0.00499474]
7 [-0.00571565] [0.00453377]
8 [-0.0051879] [0.00411514]
9 [-0.00470879] [0.00373511]
10 [-0.0042739] [0.00339014]
11 [-0.00387917] [0.00307704]
12 [-0.00352089] [0.00279284]
13 [-0.00319571] [0.0025349]
14 [-0.00290055] [0.00230078]
15 [-0.00263266] [0.00208828]
16 [-0.00238951] [0.0018954]
17 [-0.00216881] [0.00172034]
18 [-0.0019685] [0.00156145]
19 [-0.00178669] [0.00141724]
20 [-0.00162167] [0.00128634]
21 [-0.0014719] [0.00116754]
22 [-0.00133595] [0.0010597]
23 [-0.00121256] [0.00096183]
24 [-0.00110057] [0.000873]
25 [-0.00099892] [0.00079237]
26 [-0.00090666] [0.00071918]
27 [-0.00082292] [0.00065276]
28 [-0.00074692] [0.00059247]
29 [-0.00067793] [0.00053775]
[[3.9707256]
[3.0251375]]
0 [-0.01034877] [0.00888634]
1 [-0.00948452] [0.00814422]
2 [-0.00843317] [0.00724144]
3 [-0.00741349] [0.00636586]
4 [-0.00648847] [0.00557155]
5 [-0.00566909] [0.00486797]
6 [-0.00494984] [0.00425036]
7 [-0.00432069] [0.00371011]
8 [-0.00377111] [0.0032382]
9 [-0.00329131] [0.0028262]
10 [-0.0028725] [0.00246657]
11 [-0.00250697] [0.0021527]
12 [-0.00218794] [0.00187876]
13 [-0.00190952] [0.00163967]
14 [-0.00166652] [0.00143102]
15 [-0.00145445] [0.00124891]
16 [-0.00126936] [0.00108998]
17 [-0.00110783] [0.00095127]
18 [-0.00096685] [0.00083022]
19 [-0.00084381] [0.00072457]
20 [-0.00073643] [0.00063236]
21 [-0.00064272] [0.00055189]
22 [-0.00056093] [0.00048166]
23 [-0.00048955] [0.00042037]
24 [-0.00042725] [0.00036687]
25 [-0.00037288] [0.00032019]
26 [-0.00032543] [0.00027944]
27 [-0.00028402] [0.00024388]
28 [-0.00024787] [0.00021284]
29 [-0.00021633] [0.00018576]
theta from own gd wth momentum
[[3.99788953]
[3.00167406]]
[[3.99946593]
[3.0004586 ]]
</pre></div>
</div>
</div>
@@ -1139,17 +1144,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.86138568]
[3.1477805 ]]
Eigenvalues of Hessian Matrix:[0.36889994 4.06507762]
0 [-10.57231587] [-11.4303589]
1 [-1.09374315e-15] [-4.626889e-15]
2 [-3.72965547e-17] [-7.31971976e-17]
3 [-3.72965547e-17] [-7.31971976e-17]
4 [-3.72965547e-17] [-7.31971976e-17]
[[4.16849001]
[3.03642937]]
Eigenvalues of Hessian Matrix:[0.3039241 4.51493779]
0 [-12.93402104] [-15.39497785]
1 [9.11944131e-15] [7.63687445e-15]
2 [2.11636264e-16] [3.19670115e-16]
3 [2.11636264e-16] [3.19670115e-16]
4 [2.11636264e-16] [3.19670115e-16]
beta from own Newton code
[[3.86138568]
[3.1477805 ]]
[[4.16849001]
[3.03642937]]
</pre></div>
</div>
</div>
@@ -1238,18 +1243,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.94897376]
[2.96037553]]
Eigenvalues of Hessian Matrix:[0.32588151 4.12462963]
theta from own gd
[[3.94897376]
[2.96037553]]
[[4.37133465]
[2.74809387]]
Eigenvalues of Hessian Matrix:[0.32760411 4.2384333 ]
</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.37133465]
[2.74809387]]
</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.95568161]
[2.9638104 ]]
[[4.31985268]
[2.72067593]]
</pre></div>
</div>
</div>
@@ -1331,15 +1338,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.1880258 ]
[2.90273253]]
Eigenvalues of Hessian Matrix:[0.32354671 4.36490166]
[[4.34039341]
[2.74045887]]
Eigenvalues of Hessian Matrix:[0.31262618 4.15129596]
theta from own gd
[[4.18757012]
[2.9031162 ]]
[[4.340226 ]
[2.74060714]]
theta from own sdg with momentum
[[4.11556912]
[2.89211256]]
[[4.30982672]
[2.69332574]]
</pre></div>
</div>
</div>
@@ -1414,9 +1421,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.0004377 ]
[2.99782503]
[4.0020899 ]]
[[2.0009282 ]
[2.99447213]
[4.00526145]]
</pre></div>
</div>
</div>
@@ -1498,9 +1505,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.99457257]
[2.99607686]
[3.99588057]]
[[1.99998409]
[2.99993515]
[4.00003694]]
</pre></div>
</div>
</div>
@@ -1586,9 +1593,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.00003022]
[2.99976375]
[4.00024415]]
[[2.00011851]
[2.99937234]
[4.00068042]]
</pre></div>
</div>
</div>
@@ -1661,7 +1668,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 0x11fa3db20&gt;]
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[&lt;matplotlib.lines.Line2D at 0x125606520&gt;]
</pre></div>
</div>
<img alt="_images/exercisesweek41_39_2.png" src="_images/exercisesweek41_39_2.png" />
@@ -1696,7 +1703,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 0x10746eeb0&gt;
<div class="output text_plain highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>&lt;matplotlib.collections.PathCollection at 0x1253cc610&gt;
</pre></div>
</div>
<img alt="_images/exercisesweek41_41_1.png" src="_images/exercisesweek41_41_1.png" />