tensorflow problems with chapter 12

This commit is contained in:
Morten Hjorth-Jensen
2021-10-26 22:24:12 +02:00
parent 6c7054581f
commit 6c32c5b5e2
89 changed files with 665 additions and 827 deletions
+60 -62
View File
@@ -1111,10 +1111,10 @@ covariance matrix through the <strong>np.linalg.eig()</strong> function.</p>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.05805002932374468
4.309519578637819
[[ 1.23033954 3.6804336 ]
[ 3.6804336 11.92527504]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.0119839668275544
3.9026821944532157
[[ 1.21805483 3.6417002 ]
[ 3.6417002 11.67950066]]
</pre></div>
</div>
</div>
@@ -1151,10 +1151,10 @@ a more brute force way. Here we scale the mean values for each column of the des
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.09198004868226574
1.9493620821393187
[[1. 0.68904673]
[0.68904673 1. ]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>0.08283349271892
1.6319972672199556
[[1. 0.65062105]
[0.65062105 1. ]]
</pre></div>
</div>
</div>
@@ -1184,30 +1184,30 @@ this matrix we easily see that it is a positive definite matrix.</p>
</div>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[[-1.13352411e+00 -4.86145508e+00]
[ 5.06793578e-01 2.24339370e+00]
[ 4.08359441e-03 -1.44109702e+00]
[-2.02972824e-01 -1.17393096e+00]
[ 9.99703985e-01 5.00745587e+00]
[-1.05430325e-01 3.31446832e-02]
[ 4.31082669e-01 6.38783434e-01]
[ 3.40259257e-02 5.84099240e-01]
[-8.44862840e-01 -2.71546272e+00]
[ 3.11100342e-01 1.68506886e+00]]
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[[ 0.30199745 0.72164987]
[ 1.04858244 2.95539603]
[ 0.46840512 1.52940309]
[ 0.24117177 1.78848481]
[-1.38690487 -4.17705119]
[-0.65735283 -2.46141305]
[ 0.94916469 2.81774574]
[-0.52449732 -2.22140879]
[-0.66999836 -2.66511337]
[ 0.22943192 1.71230687]]
0 1
0 -1.133524 -4.861455
1 0.506794 2.243394
2 0.004084 -1.441097
3 -0.202973 -1.173931
4 0.999704 5.007456
5 -0.105430 0.033145
6 0.431083 0.638783
7 0.034026 0.584099
8 -0.844863 -2.715463
9 0.311100 1.685069
0 0.301997 0.721650
1 1.048582 2.955396
2 0.468405 1.529403
3 0.241172 1.788485
4 -1.386905 -4.177051
5 -0.657353 -2.461413
6 0.949165 2.817746
7 -0.524497 -2.221409
8 -0.669998 -2.665113
9 0.229432 1.712307
0 1
0 1.000000 0.958527
1 0.958527 1.000000
0 1.000000 0.975127
1 0.975127 1.000000
</pre></div>
</div>
</div>
@@ -1264,37 +1264,37 @@ this matrix we easily see that it is a positive definite matrix.</p>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span> 0 1 2 3 4 5 6 7 \
0 0.0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
1 0.0 0.082212 0.080493 0.081616 0.077560 0.073611 0.073557 0.069528
2 0.0 0.080493 0.080583 0.082413 0.079267 0.075998 0.075624 0.072071
3 0.0 0.081616 0.082413 0.087107 0.084071 0.080840 0.082136 0.078414
4 0.0 0.077560 0.079267 0.084071 0.081732 0.079085 0.080069 0.076853
5 0.0 0.073611 0.075998 0.080840 0.079085 0.076946 0.077662 0.074900
6 0.0 0.073557 0.075624 0.082136 0.080069 0.077662 0.079815 0.076731
7 0.0 0.069528 0.072071 0.078414 0.076853 0.074900 0.076731 0.074079
8 0.0 0.065794 0.068700 0.074858 0.073728 0.072170 0.073713 0.071447
9 0.0 0.062352 0.065534 0.071499 0.070739 0.069526 0.070812 0.068888
10 0.0 0.065582 0.068203 0.075503 0.074125 0.072352 0.074961 0.072447
11 0.0 0.062022 0.064909 0.071917 0.070915 0.069494 0.071782 0.069625
12 0.0 0.058765 0.061857 0.068581 0.067904 0.066793 0.068790 0.066951
13 0.0 0.055788 0.059038 0.065492 0.065096 0.064256 0.065991 0.064434
14 0.0 0.053069 0.056441 0.062636 0.062486 0.061885 0.063380 0.062076
1 0.0 0.096033 0.089499 0.100065 0.095636 0.091356 0.093135 0.089366
2 0.0 0.089499 0.084679 0.095430 0.091860 0.088348 0.090343 0.087109
3 0.0 0.100065 0.095430 0.109996 0.106272 0.102568 0.105983 0.102429
4 0.0 0.095636 0.091860 0.106272 0.103072 0.099840 0.103254 0.100074
5 0.0 0.091356 0.088348 0.102568 0.099840 0.097041 0.100443 0.097606
6 0.0 0.093135 0.090343 0.105983 0.103254 0.100443 0.104606 0.101680
7 0.0 0.089366 0.087109 0.102429 0.100074 0.097606 0.101680 0.099049
8 0.0 0.085816 0.084032 0.099028 0.097007 0.094850 0.098834 0.096471
9 0.0 0.082468 0.081101 0.095771 0.094052 0.092175 0.096070 0.093951
10 0.0 0.085269 0.083748 0.099374 0.097448 0.095375 0.099827 0.097488
11 0.0 0.082003 0.080845 0.096087 0.094440 0.092628 0.096955 0.094852
12 0.0 0.078938 0.078099 0.092968 0.091572 0.089996 0.094201 0.092313
13 0.0 0.076058 0.075503 0.090008 0.088838 0.087475 0.091561 0.089869
14 0.0 0.073350 0.073045 0.087198 0.086231 0.085061 0.089033 0.087519
8 9 10 11 12 13 14
0 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000
1 0.065794 0.062352 0.065582 0.062022 0.058765 0.055788 0.053069
2 0.068700 0.065534 0.068203 0.064909 0.061857 0.059038 0.056441
3 0.074858 0.071499 0.075503 0.071917 0.068581 0.065492 0.062636
4 0.073728 0.070739 0.074125 0.070915 0.067904 0.065096 0.062486
5 0.072170 0.069526 0.072352 0.069494 0.066793 0.064256 0.061885
6 0.073713 0.070812 0.074961 0.071782 0.068790 0.065991 0.063380
7 0.071447 0.068888 0.072447 0.069625 0.066951 0.064434 0.062076
8 0.069161 0.066912 0.069940 0.067442 0.065059 0.062803 0.060678
9 0.066912 0.064945 0.067492 0.065289 0.063171 0.061154 0.059245
10 0.069940 0.067492 0.071541 0.068800 0.066196 0.063738 0.061430
11 0.067442 0.065289 0.068800 0.066372 0.064050 0.061846 0.059767
12 0.065059 0.063171 0.066196 0.064050 0.061983 0.060011 0.058141
13 0.062803 0.061154 0.063738 0.061846 0.060011 0.058249 0.056570
14 0.060678 0.059245 0.061430 0.059767 0.058141 0.056570 0.055065
1 0.085816 0.082468 0.085269 0.082003 0.078938 0.076058 0.073350
2 0.084032 0.081101 0.083748 0.080845 0.078099 0.075503 0.073045
3 0.099028 0.095771 0.099374 0.096087 0.092968 0.090008 0.087198
4 0.097007 0.094052 0.097448 0.094440 0.091572 0.088838 0.086231
5 0.094850 0.092175 0.095375 0.092628 0.089996 0.087475 0.085061
6 0.098834 0.096070 0.099827 0.096955 0.094201 0.091561 0.089033
7 0.096471 0.093951 0.097488 0.094852 0.092313 0.089869 0.087519
8 0.094138 0.091843 0.095173 0.092754 0.090414 0.088152 0.085968
9 0.091843 0.089754 0.092891 0.090673 0.088516 0.086423 0.084394
10 0.095173 0.092891 0.096568 0.094135 0.091779 0.089500 0.087297
11 0.092754 0.090673 0.094135 0.091901 0.089727 0.087616 0.085567
12 0.090414 0.088516 0.091779 0.089727 0.087721 0.085765 0.083859
13 0.088152 0.086423 0.089500 0.087616 0.085765 0.083951 0.082179
14 0.085968 0.084394 0.087297 0.085567 0.083859 0.082179 0.080529
</pre></div>
</div>
</div>
@@ -2150,15 +2150,13 @@ set of <span class="math notranslate nohighlight">\(\lambda\)</span> values.</p>
</div>
<div class="cell_output docutils container">
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>[ 2.03099776 -0.17917768 5.18029127]
</pre></div>
</div>
<div class="output stream highlight-myst-ansi notranslate"><div class="highlight"><pre><span></span>Training MSE for OLS
Training MSE for OLS
0.009163470508352228
Test MSE OLS
0.008675369724976777
</pre></div>
</div>
<img alt="_images/chapter2_249_2.png" src="_images/chapter2_249_2.png" />
<img alt="_images/chapter2_249_1.png" src="_images/chapter2_249_1.png" />
</div>
</div>
<p>Both these example send a clear message. The addition of a