Compare commits

..

227 Commits

Author SHA1 Message Date
udlbook
5302b32929 Created using Colab 2025-05-22 13:04:04 -04:00
udlbook
d5586e57fc Created using Colab 2025-05-22 12:12:42 -04:00
udlbook
d0acc42d81 Created using Colab 2025-05-22 12:11:38 -04:00
udlbook
f3188ac35a Created using Colab 2025-05-16 15:45:18 -04:00
udlbook
ad1b6a558b Created using Colab 2025-05-16 15:39:03 -04:00
udlbook
7eadd56eaa Created using Colab 2025-05-16 15:32:56 -04:00
udlbook
53c1357df7 Created using Colab 2025-05-16 15:21:19 -04:00
udlbook
8d862ede26 Created using Colab 2025-05-16 12:20:43 -04:00
udlbook
44bbfbed91 Created using Colab 2025-04-20 10:42:09 -04:00
udlbook
f65f0b1ddf Created using Colab 2025-04-20 10:25:38 -04:00
udlbook
1d6d6b6fbe Update SAT_Sudoku.ipynb 2025-04-20 10:24:02 -04:00
udlbook
62779ec260 Created using Colab 2025-04-20 10:23:27 -04:00
udlbook
be3edb60f9 Created using Colab 2025-04-19 16:35:23 -04:00
udlbook
b9403e091b Created using Colab 2025-04-19 16:35:10 -04:00
udlbook
2c916d9a87 Created using Colab 2025-04-19 16:30:00 -04:00
udlbook
310b71e203 Created using Colab 2025-04-19 12:48:29 -04:00
udlbook
fcb1333aed Created using Colab 2025-04-19 12:44:38 -04:00
udlbook
c39267b3b4 Created using Colab 2025-04-19 12:43:00 -04:00
udlbook
4291ed453c Created using Colab 2025-04-19 12:19:24 -04:00
udlbook
ab2ff3177a Add files via upload 2025-04-09 12:58:10 -04:00
udlbook
c2a4d40da3 Created using Colab 2025-04-04 15:15:23 -04:00
udlbook
aa75d3ad73 Created using Colab 2025-04-03 17:11:57 -04:00
udlbook
1f0c224a7d Created using Colab 2025-04-03 17:05:24 -04:00
udlbook
eb29a28284 Created using Colab 2025-04-03 16:48:48 -04:00
udlbook
7648203767 Created using Colab 2025-04-03 16:35:24 -04:00
udlbook
64e1d82d04 Created using Colab 2025-03-31 18:10:24 -04:00
udlbook
f7450d1875 Created using Colab 2025-03-31 18:07:05 -04:00
Simon Prince
884a7e358b Merge branch 'main' of https://github.com/udlbook/udlbook
commit.
2025-03-28 14:45:38 -04:00
Simon Prince
2016977f30 New release 2025-03-28 14:44:01 -04:00
udlbook
f88127c0d2 Created using Colab 2025-03-27 17:56:09 -04:00
udlbook
a637eec888 Created using Colab 2025-03-27 17:52:22 -04:00
udlbook
ddd6bf9149 Created using Colab 2025-03-27 17:47:29 -04:00
udlbook
0b41646bf3 Add files via upload 2025-03-27 12:57:57 -04:00
udlbook
16afbcdf83 Created using Colab 2025-03-24 15:35:15 -04:00
udlbook
b0add1f8e2 Merge pull request #277 from ullizen/patch-1
Update 4_2_Clipping_functions.ipynb
2025-03-24 15:31:02 -04:00
ullizen
03ebe5a039 Update 4_2_Clipping_functions.ipynb 2025-03-08 10:52:03 +01:00
udlbook
41e8262f20 Created using Colab 2025-03-04 16:39:17 -05:00
udlbook
2c6e1cb9f8 Created using Colab 2025-03-04 16:32:31 -05:00
udlbook
6c99c6b7eb Created using Colab 2025-03-04 14:31:39 -05:00
udlbook
0988ae8bd0 Merge pull request #273 from fredhsu/patch-1
Update 7_2_Backpropagation.ipynb to fix equation references
2025-03-04 14:00:59 -05:00
Fred Hsu
2cca6dec75 Update 7_2_Backpropagation.ipynb to fix equation references
Some off by one errors in the equation references.
2025-02-27 15:39:46 -08:00
udlbook
49d74b66a9 Created using Colab 2025-02-16 10:25:23 -05:00
udlbook
13c0ad30fe Merge pull request #270 from MarkGotham/main
"TO DO" > "TODO
2025-02-16 10:22:59 -05:00
udlbook
95549683c4 Created using Colab 2025-02-11 15:13:30 -05:00
Mark Gotham
9649ce382b "TO DO" > "TODO
In [commit 6072ad4](6072ad4), @KajvanRijn kindly changed all "TO DO" to "TODO" in the code blocks. That's useful. In addition, it should be changed (as here) in the instructions. Then there's no doubt or issue for anyone searching all instances.
2025-02-11 15:11:06 +00:00
udlbook
666cbb02d5 Created using Colab 2025-02-01 14:56:25 -05:00
udlbook
f0337130cb Created using Colab 2025-01-30 11:35:39 -05:00
udlbook
472571aef0 Created using Colab 2025-01-29 10:39:29 -05:00
udlbook
13b39c2f72 Created using Colab 2025-01-29 10:32:57 -05:00
udlbook
84a11d68ed Created using Colab 2025-01-29 10:29:54 -05:00
udlbook
653d2f7b84 Created using Colab 2025-01-29 10:28:29 -05:00
udlbook
a7ed3e2c34 Created using Colab 2025-01-29 10:24:36 -05:00
udlbook
40a2c3ca8b Created using Colab 2025-01-29 10:17:58 -05:00
udlbook
fb66cd682d Created using Colab 2025-01-28 11:43:39 -05:00
udlbook
88e8526fa7 Created using Colab 2025-01-28 10:59:00 -05:00
udlbook
667346fbdd Created using Colab 2025-01-28 10:57:32 -05:00
udlbook
4e564088a1 Created using Colab 2025-01-28 10:50:31 -05:00
udlbook
f1c07f53bf Created using Colab 2025-01-28 10:48:39 -05:00
udlbook
623b9782e7 Created using Colab 2025-01-28 10:36:43 -05:00
udlbook
60c5a48477 Delete Trees/LinearRegression_LeastSquares.ipynb 2025-01-27 17:40:21 -05:00
udlbook
b4688bda68 Created using Colab 2025-01-27 17:38:54 -05:00
Simon Prince
faf34e0887 fixed typo 2025-01-23 16:52:43 -05:00
Simon Prince
8f2ef53eab Merge branch 'main' of https://github.com/udlbook/udlbook
Trying to fix website problems
2025-01-23 16:25:08 -05:00
Simon Prince
2f0339341c bib file, eqns 2025-01-23 16:11:01 -05:00
udlbook
f8acbaab82 Add files via upload 2025-01-23 15:49:08 -05:00
udlbook
2aaaef0838 Delete UDL_Equations.pdf 2025-01-23 15:47:55 -05:00
udlbook
9a2039d392 Add files via upload 2025-01-23 15:40:43 -05:00
udlbook
6d76e47849 Created using Colab 2024-12-29 17:13:26 -05:00
udlbook
b5c65665b6 Update 10_4_Downsampling_and_Upsampling.ipynb 2024-12-18 09:06:15 -05:00
udlbook
dd9a56d96b Created using Colab 2024-12-16 16:06:30 -05:00
udlbook
9b71ac0487 Merge pull request #243 from aleksandrskoselevs/patch-2
Update 15_2_Wasserstein_Distance.ipynb
2024-12-02 15:52:24 -05:00
udlbook
eaff933ff7 Created using Colab 2024-12-02 15:43:55 -05:00
udlbook
c3dfe95700 Merge pull request #249 from ThePiep/fix-TODO
Change "TO DO" in comments to "TODO"
2024-12-02 15:19:54 -05:00
Kaj van Rijn
7082ae8620 Merge branch 'main' of github.com:ThePiep/udlbook-piep 2024-11-22 15:36:33 +01:00
Kaj van Rijn
6072ad4450 Change all TO DO to TODO 2024-11-22 15:34:52 +01:00
udlbook
33197fde36 Add files via upload 2024-11-21 16:45:29 -05:00
udlbook
6d425c04d4 Update 3_3_Shallow_Network_Regions.ipynb 2024-11-18 15:33:42 -05:00
udlbook
57c95132d3 Created using Colab 2024-11-12 17:11:44 -05:00
udlbook
2b0ac95740 Created using Colab 2024-11-08 12:31:21 -05:00
udlbook
d5f198f2d8 Add files via upload 2024-11-04 15:25:38 -05:00
udlbook
4edd8c923d Add files via upload 2024-10-30 16:51:41 -04:00
aleksandrskoselevs
1adb96e006 Update 15_2_Wasserstein_Distance.ipynb 2024-10-30 09:19:22 +01:00
udlbook
3801b8d52d Created using Colab 2024-10-24 16:45:43 -04:00
udlbook
dc6b346bda Created using Colab 2024-10-24 16:43:14 -04:00
udlbook
5eb264540d Created using Colab 2024-10-24 16:40:27 -04:00
udlbook
7ba844f2b5 Created using Colab 2024-10-24 16:04:27 -04:00
aleksandrskoselevs
be86733a93 Update 15_2_Wasserstein_Distance.ipynb
Scaling of the distance matrix was not mentioned in the book.
2024-10-22 12:11:15 +02:00
udlbook
d101aa428b Merge pull request #236 from aleksandrskoselevs/patch-1
Update 13_4_Graph_Attention_Networks.ipynb
2024-10-15 17:24:40 -04:00
aleksandrskoselevs
8c6e40daee Update 13_4_Graph_Attention_Networks.ipynb
`phi` is defined in the book as a column vector
2024-10-11 10:54:05 +02:00
udlbook
efafb942eb Add files via upload 2024-10-01 15:14:01 -04:00
udlbook
b10a2b6940 Delete UDL_Answer_Booklet.pdf 2024-10-01 15:13:35 -04:00
udlbook
ede7247a0c Add files via upload 2024-10-01 15:13:14 -04:00
udlbook
c3b97af456 Created using Colab 2024-09-16 09:21:22 -04:00
udlbook
e1df2156a3 Created using Colab 2024-09-16 09:19:49 -04:00
udlbook
f887835646 Created using Colab 2024-09-16 09:18:12 -04:00
udlbook
e9c8d846f2 Created using Colab 2024-09-16 07:36:27 -04:00
udlbook
b7869e8b41 Add files via upload 2024-08-28 13:01:31 -04:00
udlbook
747ec9efe1 Merge pull request #227 from aleksandrskoselevs/main
Notebook 9_5_Augmentation - Removed duplicate weight initialization
2024-08-23 18:17:17 -04:00
udlbook
58dfb0390c Merge pull request #224 from muddlebee/udlbook
fix(8.1) : error in Chap08\8_1_MNIST_1D_Performance.ipynb
2024-08-23 14:24:32 -04:00
aleksandrskoselevs
3aeb8db4cd cleaner diff 2024-08-23 10:29:52 +02:00
aleksandrskoselevs
305a055079 Revert "Remove duplicate weight initialization"
This reverts commit 87cf590af9.
2024-08-23 10:29:04 +02:00
aleksandrskoselevs
87cf590af9 Remove duplicate weight initialization 2024-08-23 09:57:38 +02:00
muddlebee
ccedbb72e7 fix(8.1) : error in Chap08\8_1_MNIST_1D_Performance.ipynb 2024-08-17 19:20:02 +05:30
muddlebee
b423a67855 fix(8.1) : error in Chap08\8_1_MNIST_1D_Performance.ipynb 2024-08-17 03:50:15 +05:30
muddlebee
3c8dab14e6 fix(8.1) : error in Chap08\8_1_MNIST_1D_Performance.ipynb 2024-08-17 03:48:56 +05:30
udlbook
ab73ae785b Add files via upload 2024-08-05 18:47:05 -04:00
udlbook
df86bbba04 Merge pull request #219 from jhrcek/jhrcek/fix-duplicate-words
Fix duplicate word occurrences in notebooks
2024-07-30 16:07:03 -04:00
udlbook
a9868e6da8 Rename README.md to src/README.md 2024-07-30 16:01:39 -04:00
Jan Hrček
fed3962bce Fix markdown headings 2024-07-30 11:25:47 +02:00
Jan Hrček
c5fafbca97 Fix duplicate word occurrences in notebooks 2024-07-30 11:16:30 +02:00
udlbook
5f16e0f9bc Fixed problem with example label. 2024-07-29 18:52:49 -04:00
udlbook
121c81a04e Update index.html 2024-07-22 18:42:22 -04:00
udlbook
e968741846 Add files via upload 2024-07-22 17:09:30 -04:00
udlbook
37011065d7 Add files via upload 2024-07-22 17:09:15 -04:00
udlbook
afd20d0364 Update 17_1_Latent_Variable_Models.ipynb 2024-07-22 15:03:17 -04:00
udlbook
0d135f1ee7 Fixed problems with MNIST1D 2024-07-19 15:55:44 -04:00
udlbook
54a020304e Merge pull request #211 from qualiaMachine/patch-1
Update 8_3_Double_Descent.ipynb
2024-07-10 15:53:00 -04:00
Chris Endemann
ccbbc4126e Update 8_3_Double_Descent.ipynb
Apologies, accidentally removed the "open in colab" button in the pull request you accepted earlier today. This corrects the mistake!
2024-07-10 14:15:21 -05:00
udlbook
d3273c99e2 Merge pull request #210 from qualiaMachine/main
Add vertical line to double descent plot indicating where count(weights) = count(train)
2024-07-10 14:33:31 -04:00
Chris Endemann
f9e45c976c Merge branch 'udlbook:main' into main 2024-07-10 09:43:18 -05:00
Chris Endemann
b005cec9c1 Update 8_3_Double_Descent.ipynb
I added a little code to include a vertical dashed line on the plot representing where total_weights = number of train observations.  I also moved n_epochs as an argument to fit_model() so learners can play around with the impact of n_epochs more easily.
2024-07-10 09:42:38 -05:00
udlbook
b8a91ad34d Merge pull request #208 from SwayStar123/patch-4
Update 12_2_Multihead_Self_Attention.ipynb
2024-07-09 17:53:31 -04:00
SwayStar123
a2a86c27bc Update 12_2_Multihead_Self_Attention.ipynb
title number is incorrect, its actually 12.2
2024-07-06 17:19:13 +05:30
udlbook
d80d04c2d4 Add files via upload 2024-07-02 14:42:18 -04:00
udlbook
c1f0181653 Update 10_4_Downsampling_and_Upsampling.ipynb 2024-07-02 14:24:36 -04:00
udlbook
6e18234d24 Merge pull request #206 from tomheaton/github-icon
website: Add GitHub social link
2024-07-02 14:23:00 -04:00
udlbook
5730c05547 Create LICENSE (MIT) 2024-07-01 09:34:05 -04:00
Tom Heaton
ccb80c16b8 GitHub social link 2024-06-27 19:41:34 +01:00
Tom Heaton
87387b2b4c fix import 2024-06-27 19:38:52 +01:00
Simon Prince
06eaec9749 Fix file extension 2024-06-24 17:49:03 -04:00
udlbook
9aeda14efa Merge pull request #203 from tomheaton/more-news
website: changes to news section
2024-06-21 09:51:51 -04:00
Tom Heaton
d1df6426b2 cleanup some state and functions 2024-06-21 10:21:11 +01:00
Tom Heaton
43b8fa3685 fix pdf download texts 2024-06-21 10:19:07 +01:00
Tom Heaton
ca6e4b29ac simple show more news working 2024-06-21 10:18:16 +01:00
Tom Heaton
267d6ccb7f remove book selling news 2024-06-20 10:43:35 +01:00
Tom Heaton
735947b728 dynamic rendering for news items 2024-06-20 10:39:17 +01:00
Tom Heaton
251aef1876 fix vite error 2024-06-20 10:12:05 +01:00
Tom Heaton
07ff6c06b1 fix import 2024-06-20 10:11:17 +01:00
Tom Heaton
29e4cec04e fix eslint error 2024-06-20 10:10:53 +01:00
Simon Prince
c3ce38410c minor fixes to website 2024-06-19 12:08:06 -04:00
udlbook
646e60ed95 Merge pull request #202 from tomheaton/path-aliases-new
website: Add path aliases + some fixes
2024-06-19 12:03:03 -04:00
Tom Heaton
5e61bcf694 fix links 2024-06-19 15:35:44 +01:00
Tom Heaton
54399a3c68 fix hero section on mobile 2024-06-19 15:35:17 +01:00
Tom Heaton
3926ff41ea fix navbar naming 2024-06-19 15:16:58 +01:00
Tom Heaton
9c34bfed02 Rename NavBar_temp to Navbar 2024-06-19 15:16:17 +01:00
Tom Heaton
9176623331 Rename NavBar to NavBar_temp 2024-06-19 15:15:45 +01:00
Tom Heaton
5534df187e refactor index page 2024-06-19 15:15:16 +01:00
Tom Heaton
9b58b2862f remove old dep 2024-06-19 15:14:34 +01:00
Tom Heaton
2070ac4400 delete old code 2024-06-19 15:13:46 +01:00
Tom Heaton
393e4907dc path aliases 2024-06-19 15:13:34 +01:00
udlbook
e850676722 Merge pull request #200 from tomheaton/dynamic
website dynamic data
2024-06-19 09:08:12 -04:00
Tom Heaton
796f17ed90 media dynamic rendering (partial) 2024-06-18 12:40:09 +01:00
Tom Heaton
dc0301a86e footer dynamic rendering 2024-06-18 12:33:53 +01:00
Tom Heaton
813f628e4e fixes 2024-06-18 12:23:48 +01:00
Tom Heaton
3ae7d68f6e more dynamic rendering 2024-06-18 12:21:35 +01:00
Tom Heaton
a96a14999f instructors dynamic rendering 2024-06-18 12:03:39 +01:00
Tom Heaton
f91e878eef notebooks dynamic rendering 2024-06-18 11:47:46 +01:00
Tom Heaton
9b89499b75 delete build dir 2024-06-17 21:53:13 +01:00
Simon Prince
7d6ac5e34f fixed tiny mistake in link 2024-06-17 16:42:54 -04:00
udlbook
55dbe7e0c4 Merge pull request #198 from tomheaton/cleanup
website code cleanup
2024-06-17 16:15:54 -04:00
udlbook
1cf21ea61a Created using Colab 2024-06-17 15:11:34 -04:00
Tom Heaton
e4191beb79 refactor styles 2024-06-17 15:28:43 +01:00
Tom Heaton
10b9dea9a4 change build dir to dist 2024-06-17 15:24:35 +01:00
Tom Heaton
414eeb3557 formatting 2024-06-17 15:22:26 +01:00
Tom Heaton
f126809572 Merge branch 'main' into cleanup 2024-06-17 15:20:21 +01:00
Tom Heaton
2a30c49d22 fix deploy 2024-06-17 14:52:47 +01:00
udlbook
bb32fe0cdf Created using Colab 2024-06-11 18:35:42 -04:00
udlbook
1ee756cf9a Update 17_3_Importance_Sampling.ipynb 2024-06-11 15:07:57 -04:00
udlbook
742d922ce7 Created using Colab 2024-06-07 15:21:45 -04:00
Simon Prince
c02eea499c Merge branch 'main' of https://github.com/udlbook/udlbook 2024-06-06 15:10:46 -04:00
Simon Prince
cb94b61abd new NKT tutorial 2024-06-06 15:02:21 -04:00
Tom Heaton
447bb82e2f remove nav listener on unmount 2024-06-06 00:46:46 +01:00
Tom Heaton
77da5694bb use default exports 2024-06-06 00:38:13 +01:00
Tom Heaton
96c7e41c9d update deps 2024-06-06 00:31:00 +01:00
Tom Heaton
625d1e29bb code cleanup 2024-06-06 00:23:19 +01:00
Tom Heaton
3cf0c4c418 add readme 2024-06-06 00:08:09 +01:00
Tom Heaton
03c92541ad formatting 2024-06-05 23:58:58 +01:00
Tom Heaton
def3e5234b setup formatting 2024-06-05 23:56:37 +01:00
Tom Heaton
815adb9b21 cleanup package.json 2024-06-05 23:51:49 +01:00
udlbook
5ba28e5b56 Update 12_2_Multihead_Self_Attention.ipynb 2024-06-05 16:11:17 -04:00
udlbook
8566a7322f Merge pull request #196 from tomheaton/website-changes
Migrate from `create-react-app` to `vite`
2024-06-05 16:09:55 -04:00
udlbook
c867e67e8c Created using Colab 2024-06-05 10:55:51 -04:00
udlbook
cba27b3da4 Add files via upload 2024-05-27 18:15:58 -04:00
Tom Heaton
1c706bd058 update eslint ignore 2024-05-25 01:38:19 +01:00
Tom Heaton
72514994bf delete dist dir 2024-05-25 00:53:16 +01:00
Tom Heaton
872926c17e remove dist dir from .gitignore 2024-05-25 00:51:05 +01:00
Tom Heaton
0dfeb169be fix build dir 2024-05-25 00:50:34 +01:00
Tom Heaton
89a0532283 vite 2024-05-25 00:07:44 +01:00
udlbook
af5a719496 Merge pull request #195 from SwayStar123/patch-3
Fix typo in 7_2_Backpropagation.ipynb
2024-05-23 15:02:54 -04:00
SwayStar123
56c31efc90 Update 7_2_Backpropagation.ipynb 2024-05-23 14:59:55 +05:30
udlbook
06fc37c243 Add files via upload 2024-05-22 15:41:23 -04:00
udlbook
45793f02f8 Merge pull request #189 from ferdiekrammer/patch-1
Update 3_3_Shallow_Network_Regions.ipynb
2024-05-22 15:22:55 -04:00
udlbook
7c4cc1ddb4 Merge pull request #192 from SwayStar123/patch-2
Fix typo in 6_5_Adam.ipynb
2024-05-22 15:15:28 -04:00
SwayStar123
35b6f67bbf Update 6_5_Adam.ipynb 2024-05-22 12:59:03 +05:30
ferdiekrammer
194baf622a Update 3_3_Shallow_Network_Regions.ipynb
removes  <br> correcting the format of the equation in the notebook
2024-05-18 01:15:29 +01:00
udlbook
a547fee3f4 Created using Colab 2024-05-16 16:30:16 -04:00
udlbook
ea4858e78e Created using Colab 2024-05-16 16:29:05 -04:00
udlbook
444b06d5c2 Created using Colab 2024-05-16 16:27:48 -04:00
udlbook
98bce9edb5 Created using Colab 2024-05-16 16:25:26 -04:00
udlbook
37e9ae2311 Created using Colab 2024-05-16 16:24:45 -04:00
udlbook
ea1b6ad998 Created using Colab 2024-05-16 16:22:35 -04:00
udlbook
d17a5a3872 Created using Colab 2024-05-16 16:21:10 -04:00
udlbook
3e7e059bff Created using Colab 2024-05-16 16:19:57 -04:00
udlbook
445ad11c46 Created using Colab 2024-05-16 16:18:07 -04:00
udlbook
6928b50966 Created using Colab 2024-05-16 16:16:44 -04:00
udlbook
e1d34ed561 Merge pull request #185 from DhruvPatel01/chap8_fixes
Fixed 8.1 Notebook to install mnist1d
2024-05-16 16:14:53 -04:00
udlbook
f3528f758b Merge pull request #187 from SwayStar123/patch-1
Remove redundant `to`
2024-05-16 16:02:25 -04:00
udlbook
5c7a03172a Merge pull request #188 from yrahal/main
Fix more Chap09 tiny typos
2024-05-16 16:01:49 -04:00
Youcef Rahal
0233131b07 Notebook 9.5 2024-05-12 15:27:57 -04:00
SwayStar123
8200299e64 Update 2_1_Supervised_Learning.ipynb 2024-05-12 15:01:36 +05:30
Youcef Rahal
2ac42e70d3 Fix more Chap09 tiny typos 2024-05-11 15:20:11 -04:00
udlbook
dd0eaeb781 Add files via upload 2024-05-10 10:14:29 -04:00
Dhruv Patel
2cdff544f3 Fixed to install mnist1d for collab 2024-05-10 09:32:20 +05:30
Dhruv Patel
384e122c5f Fixed mnist1d installation for collab 2024-05-10 09:25:05 +05:30
Youcef Rahal
1343b68c60 Fix more Chap09 tiny typos 2024-05-09 17:51:53 -04:00
udlbook
30420a2f92 Merge pull request #183 from yrahal/main
Fix typos in Chap09 notebooks
2024-05-08 17:30:27 -04:00
Youcef Rahal
89e8ebcbc5 Fix typos in Chap09 notebooks 2024-05-06 20:20:35 -04:00
udlbook
14b751ff47 Add files via upload 2024-05-01 17:11:24 -04:00
udlbook
80e99ef2da Created using Colab 2024-05-01 16:43:15 -04:00
udlbook
46214f64bc Delete Old directory 2024-05-01 09:45:28 -04:00
udlbook
c875fb0361 Added correct answer 2024-04-23 15:57:56 -04:00
udlbook
451ccc0832 Created using Colab 2024-04-23 15:43:27 -04:00
Simon Prince
4b939b7426 Merge branch 'main' of https://github.com/udlbook/udlbook 2024-04-18 17:41:24 -04:00
Simon Prince
2d300a16a1 Final website tweaks 2024-04-18 17:41:04 -04:00
udlbook
d057548be9 Add files via upload 2024-04-18 17:40:08 -04:00
udlbook
75976a32d0 Delete UDL_Answer_Booklet.pdf 2024-04-18 17:38:42 -04:00
udlbook
48b204df2c Add files via upload 2024-04-18 17:38:16 -04:00
170 changed files with 29781 additions and 25711 deletions

10
.editorconfig Normal file
View File

@@ -0,0 +1,10 @@
root = true
[*.{js,jsx,ts,tsx,md,mdx,json,cjs,mjs,css}]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
max_line_length = 100

18
.eslintrc.cjs Normal file
View File

@@ -0,0 +1,18 @@
module.exports = {
root: true,
env: { browser: true, es2020: true, node: true },
extends: [
"eslint:recommended",
"plugin:react/recommended",
"plugin:react/jsx-runtime",
"plugin:react-hooks/recommended",
],
ignorePatterns: ["build", ".eslintrc.cjs"],
parserOptions: { ecmaVersion: "latest", sourceType: "module" },
settings: { react: { version: "18.2" } },
plugins: ["react-refresh"],
rules: {
"react/jsx-no-target-blank": "off",
"react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
},
};

13
.gitignore vendored
View File

@@ -9,15 +9,22 @@
/coverage /coverage
# production # production
/build /dist
# misc # ENV
.DS_Store
.env.local .env.local
.env.development.local .env.development.local
.env.test.local .env.test.local
.env.production.local .env.production.local
# debug
npm-debug.log* npm-debug.log*
yarn-debug.log* yarn-debug.log*
yarn-error.log* yarn-error.log*
# IDE
.idea
.vscode
# macOS
.DS_Store

7
.prettierignore Normal file
View File

@@ -0,0 +1,7 @@
# ignore these directories when formatting the repo
/Blogs
/CM20315
/CM20315_2023
/Notebooks
/PDFFigures
/Slides

14
.prettierrc.cjs Normal file
View File

@@ -0,0 +1,14 @@
/** @type {import("prettier").Config} */
const prettierConfig = {
trailingComma: "all",
tabWidth: 4,
useTabs: false,
semi: true,
singleQuote: false,
bracketSpacing: true,
printWidth: 100,
endOfLine: "lf",
plugins: [require.resolve("prettier-plugin-organize-imports")],
};
module.exports = prettierConfig;

View File

@@ -31,7 +31,7 @@
"source": [ "source": [
"# Gradient flow\n", "# Gradient flow\n",
"\n", "\n",
"This notebook replicates some of the results in the the Borealis AI [blog](https://www.borealisai.com/research-blogs/gradient-flow/) on gradient flow. \n" "This notebook replicates some of the results in the Borealis AI [blog](https://www.borealisai.com/research-blogs/gradient-flow/) on gradient flow. \n"
], ],
"metadata": { "metadata": {
"id": "ucrRRJ4dq8_d" "id": "ucrRRJ4dq8_d"

View File

@@ -166,7 +166,7 @@
{ {
"cell_type": "markdown", "cell_type": "markdown",
"source": [ "source": [
"Routines to calculate the empirical and analytical NTK (i.e. the NTK with infinite hidden units) for the the shallow network" "Routines to calculate the empirical and analytical NTK (i.e. the NTK with infinite hidden units) for the shallow network"
], ],
"metadata": { "metadata": {
"id": "mxW8E5kYIzlj" "id": "mxW8E5kYIzlj"

View File

@@ -0,0 +1,432 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/github/udlbook/udlbook/blob/main/Blogs/BorealisODENumerical.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "JXsO7ce7oqeq"
},
"source": [
"# Numerical methods for ODEs\n",
"\n",
"This blog contains code that accompanies the RBC Borealis blog on numerical methods for ODEs. Contact udlbookmail@gmail.com if you find any problems."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "AnvAKtP_oqes"
},
"source": [
"Import relevant libraries"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "UF-gJyZggyrl"
},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "szWLVrSSoqet"
},
"source": [
"Define the ODE that we will be experimenting with."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "NkrGZLL6iM3P"
},
"outputs": [],
"source": [
"# The ODE that we will experiment with\n",
"def ode_lin_homog(t,x):\n",
" return 0.5 * x ;\n",
"\n",
"# The derivative of the ODE function with respect to x (needed for Taylor's method)\n",
"def ode_lin_homog_deriv_x(t,x):\n",
" return 0.5 ;\n",
"\n",
"# The derivative of the ODE function with respect to t (needed for Taylor's method)\n",
"def ode_lin_homog_deriv_t(t,x):\n",
" return 0.0 ;\n",
"\n",
"# The closed form solution (so we can measure the error)\n",
"def ode_lin_homog_soln(t,C=0.5):\n",
" return C * np.exp(0.5 * t) ;"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "In1C9wZkoqet"
},
"source": [
"This is a generic method that runs the numerical methods. It takes the initial conditions ($t_0$, $x_0$), the final time $t_1$ and the step size $h$. It also takes the ODE function itself and its derivatives (only used for Taylor's method). Finally, the parameter \"step_function\" is the method used to update (e.g., Euler's methods, Runge-Kutte 4-step)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "VZfZDJAfmyrf"
},
"outputs": [],
"source": [
"def run_numerical(x_0, t_0, t_1, h, ode_func, ode_func_deriv_x, ode_func_deriv_t, ode_soln, step_function):\n",
" x = [x_0]\n",
" t = [t_0]\n",
" while (t[-1] <= t_1):\n",
" x = x+[step_function(x[-1],t[-1],h, ode_func, ode_func_deriv_x, ode_func_deriv_t)]\n",
" t = t + [t[-1]+h]\n",
"\n",
" # Returns x,y plot plus total numerical error at last point.\n",
" return t, x, np.abs(ode_soln(t[-1])-x[-1])"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "Vfkc3-_7oqet"
},
"source": [
"Run the numerical method with step sizes of 2.0, 1.0, 0.5, 0.25, 0.125, 0.0675 and plot the results"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "1tyGbMZhoqeu"
},
"outputs": [],
"source": [
"def run_and_plot(ode, ode_deriv_x, ode_deriv_t, ode_solution, step_function):\n",
" # Specify the grid of points to draw the ODE\n",
" t = np.arange(0.04, 4.0, 0.2)\n",
" x = np.arange(0.04, 4.0, 0.2)\n",
" T, X = np.meshgrid(t,x)\n",
"\n",
" # ODE equation at these grid points (used to draw quiver-plot)\n",
" dx = ode(T,X)\n",
" dt = np.ones(dx.shape)\n",
"\n",
" # The ground truth solution\n",
" t2= np.arange(0,10,0.1)\n",
" x2 = ode_solution(t2)\n",
"\n",
" #####################################x_0, t_0, t_1, h #################################################\n",
" t_sim1,x_sim1,error1 = run_numerical(0.5, 0.0, 4.0, 2.0000, ode, ode_deriv_x, ode_deriv_t, ode_solution, step_function)\n",
" t_sim2,x_sim2,error2 = run_numerical(0.5, 0.0, 4.0, 1.0000, ode, ode_deriv_x, ode_deriv_t, ode_solution, step_function)\n",
" t_sim3,x_sim3,error3 = run_numerical(0.5, 0.0, 4.0, 0.5000, ode, ode_deriv_x, ode_deriv_t, ode_solution, step_function)\n",
" t_sim4,x_sim4,error4 = run_numerical(0.5, 0.0, 4.0, 0.2500, ode, ode_deriv_x, ode_deriv_t, ode_solution, step_function)\n",
" t_sim5,x_sim5,error5 = run_numerical(0.5, 0.0, 4.0, 0.1250, ode, ode_deriv_x, ode_deriv_t, ode_solution, step_function)\n",
" t_sim6,x_sim6,error6 = run_numerical(0.5, 0.0, 4.0, 0.0675, ode, ode_deriv_x, ode_deriv_t, ode_solution, step_function)\n",
"\n",
" # Plot the ODE and ground truth solution\n",
" fig,ax = plt.subplots()\n",
" ax.quiver(T,X,dt,dx, scale=35.0)\n",
" ax.plot(t2,x2,'r-')\n",
"\n",
" # Plot the numerical approximations\n",
" ax.plot(t_sim1,x_sim1,'.-',markeredgecolor='#773c23ff',markerfacecolor='#d18362', color='#d18362', markersize=10)\n",
" ax.plot(t_sim2,x_sim2,'.-',markeredgecolor='#773c23ff',markerfacecolor='#d18362', color='#d18362', markersize=10)\n",
" ax.plot(t_sim3,x_sim3,'.-',markeredgecolor='#773c23ff',markerfacecolor='#d18362', color='#d18362', markersize=10)\n",
" ax.plot(t_sim4,x_sim4,'.-',markeredgecolor='#773c23ff',markerfacecolor='#d18362', color='#d18362', markersize=10)\n",
" ax.plot(t_sim5,x_sim5,'.-',markeredgecolor='#773c23ff',markerfacecolor='#d18362', color='#d18362', markersize=10)\n",
" ax.plot(t_sim6,x_sim6,'.-',markeredgecolor='#773c23ff',markerfacecolor='#d18362', color='#d18362', markersize=10)\n",
"\n",
" ax.set_aspect('equal')\n",
" ax.set_xlim(0,4)\n",
" ax.set_ylim(0,4)\n",
"\n",
" plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "JYrq8QIwvOIy"
},
"source": [
"# Euler Method\n",
"\n",
"Define the Euler method and set up functions for plotting."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "N73xMnCukVVX"
},
"outputs": [],
"source": [
"def euler_step(x_0, t_0, h, ode_func, ode_func_deriv_x=None, ode_func_deriv_t=None):\n",
" return x_0 + h * ode_func(t_0, x_0) ;"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "4B1_PGEcsZ9H"
},
"outputs": [],
"source": [
"run_and_plot(ode_lin_homog, None, None, ode_lin_homog_soln, euler_step)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "FfwNihtkvJeX"
},
"source": [
"# Heun's Method"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "srHfNDcDxI1o"
},
"outputs": [],
"source": [
"def heun_step(x_0, t_0, h, ode_func, ode_func_deriv_x=None, ode_func_deriv_t=None):\n",
" f_x0_t0 = ode_func(t_0, x_0)\n",
" return x_0 + h/2 * ( f_x0_t0 + ode_func(t_0+h, x_0+h*f_x0_t0)) ;"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "WOApHz9xoqev"
},
"outputs": [],
"source": [
"run_and_plot(ode_lin_homog, None, None, ode_lin_homog_soln, heun_step)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "0XSzzFDIvRhm"
},
"source": [
"# Modified Euler method"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "fSXprgVJ5Yep"
},
"outputs": [],
"source": [
"def modified_euler_step(x_0, t_0, h, ode_func, ode_func_deriv_x=None, ode_func_deriv_t=None):\n",
" f_x0_t0 = ode_func(t_0, x_0)\n",
" return x_0 + h * ode_func(t_0+h/2, x_0+ h * f_x0_t0/2) ;"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "8LKSrCD2oqev"
},
"outputs": [],
"source": [
"run_and_plot(ode_lin_homog, None, None, ode_lin_homog_soln, modified_euler_step)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "yp8ZBpwooqev"
},
"source": [
"# Second order Taylor's method"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "NtBBgzWLoqev"
},
"outputs": [],
"source": [
"def taylor_2nd_order(x_0, t_0, h, ode_func, ode_func_deriv_x, ode_func_deriv_t):\n",
" f1 = ode_func(t_0, x_0)\n",
" return x_0 + h * ode_func(t_0, x_0) + (h*h/2) * (ode_func_deriv_x(t_0,x_0) * ode_func(t_0, x_0) + ode_func_deriv_t(t_0, x_0))"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "ioeeIohUoqev"
},
"outputs": [],
"source": [
"run_and_plot(ode_lin_homog, ode_lin_homog_deriv_x, ode_lin_homog_deriv_t, ode_lin_homog_soln, taylor_2nd_order)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "WcuhV5lL1zAJ"
},
"source": [
"# Fourth Order Runge Kutta"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "0NZN81Bpwu56"
},
"outputs": [],
"source": [
"def runge_kutta_4_step(x_0, t_0, h, ode_func, ode_func_deriv_x=None, ode_func_deriv_t=None):\n",
" f1 = ode_func(t_0, x_0)\n",
" f2 = ode_func(t_0+h/2,x_0+f1 * h/2)\n",
" f3 = ode_func(t_0+h/2,x_0+f2 * h/2)\n",
" f4 = ode_func(t_0+h, x_0+ f3*h)\n",
" return x_0 + (h/6) * (f1 + 2*f2 + 2*f3+f4)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "K-OxE9E6oqew"
},
"outputs": [],
"source": [
"run_and_plot(ode_lin_homog, None, None, ode_lin_homog_soln, runge_kutta_4_step)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "7JifxBhhoqew"
},
"source": [
"# Plot the error as a function of step size"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "ZoEpmlCfsi9P"
},
"outputs": [],
"source": [
"# Run systematically with a number of different step sizes and store errors for each\n",
"def get_errors(ode, ode_deriv_x, ode_deriv_t, ode_solution, step_function):\n",
" # Choose the step size h to divide the plotting interval into 1,2,4,8... segments.\n",
" # The plots in the article add a few more smaller step sizes, but this takes a while to compute.\n",
" # Add them back in if you want the full plot.\n",
" all_h = (1./np.array([1,2,4,8,16,32,64,128,256,512,1024,2048,4096])).tolist()\n",
" all_err = []\n",
"\n",
" for i in range(len(all_h)):\n",
" t_sim,x_sim,err = run_numerical(0.5, 0.0, 4.0, all_h[i], ode, ode_deriv_x, ode_deriv_t, ode_solution, step_function)\n",
" all_err = all_err + [err]\n",
"\n",
" return all_h, all_err"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "X0O0KK47xF28"
},
"outputs": [],
"source": [
"# Plot the errors\n",
"all_h, all_err_euler = get_errors(ode_lin_homog, ode_lin_homog_deriv_x, ode_lin_homog_deriv_t, ode_lin_homog_soln, euler_step)\n",
"all_h, all_err_heun = get_errors(ode_lin_homog, ode_lin_homog_deriv_x, ode_lin_homog_deriv_t, ode_lin_homog_soln, heun_step)\n",
"all_h, all_err_mod_euler = get_errors(ode_lin_homog, ode_lin_homog_deriv_x, ode_lin_homog_deriv_t, ode_lin_homog_soln, modified_euler_step)\n",
"all_h, all_err_taylor = get_errors(ode_lin_homog, ode_lin_homog_deriv_x, ode_lin_homog_deriv_t, ode_lin_homog_soln, taylor_2nd_order)\n",
"all_h, all_err_rk = get_errors(ode_lin_homog, ode_lin_homog_deriv_x, ode_lin_homog_deriv_t, ode_lin_homog_soln, runge_kutta_4_step)\n",
"\n",
"\n",
"fig, ax = plt.subplots()\n",
"ax.loglog(all_h, all_err_euler,'ro-')\n",
"ax.loglog(all_h, all_err_heun,'bo-')\n",
"ax.loglog(all_h, all_err_mod_euler,'go-')\n",
"ax.loglog(all_h, all_err_taylor,'co-')\n",
"ax.loglog(all_h, all_err_rk,'mo-')\n",
"ax.set_ylim(1e-13,1e1)\n",
"ax.set_xlim(1e-6,1e1)\n",
"ax.set_aspect(0.5)\n",
"ax.set_xlabel('Step size, $h$')\n",
"ax.set_ylabel('Error')\n",
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "BttOqpeo9MsJ"
},
"source": [
"Note that for this ODE, the Heun, Modified Euler and Taylor methods provide EXACTLY the same updates, and so the error curves for all three are identical (subject to difference is numerical rounding errors). This is not in general the case, although the general trend would be the same for each."
]
}
],
"metadata": {
"colab": {
"provenance": [],
"include_colab_link": true
},
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.10"
}
},
"nbformat": 4,
"nbformat_minor": 0
}

1127
Blogs/Borealis_NNGP.ipynb Normal file

File diff suppressed because one or more lines are too long

View File

@@ -128,7 +128,7 @@
"\n", "\n",
"In part (b) of the practical we calculate the volume of a hypersphere of radius 0.5 (i.e., of diameter 1) as a function of the radius. You will find that the volume decreases to almost nothing in high dimensions. All of the volume is in the corners of the unit hypercube (which always has volume 1). Double weird.\n", "In part (b) of the practical we calculate the volume of a hypersphere of radius 0.5 (i.e., of diameter 1) as a function of the radius. You will find that the volume decreases to almost nothing in high dimensions. All of the volume is in the corners of the unit hypercube (which always has volume 1). Double weird.\n",
"\n", "\n",
"Note that you you can check your answer by doing the calculation for 2D using the standard formula for the area of a circle and making sure it matches." "Note that you can check your answer by doing the calculation for 2D using the standard formula for the area of a circle and making sure it matches."
], ],
"metadata": { "metadata": {
"id": "b2FYKV1SL4Z7" "id": "b2FYKV1SL4Z7"

View File

@@ -199,7 +199,7 @@
{ {
"cell_type": "markdown", "cell_type": "markdown",
"source": [ "source": [
"The left is model output and the right is the model output after the sigmoid has been applied, so it now lies in the range [0,1] and represents the probability, that y=1. The black dots show the training data. We'll compute the the likelihood and the negative log likelihood." "The left is model output and the right is the model output after the sigmoid has been applied, so it now lies in the range [0,1] and represents the probability, that y=1. The black dots show the training data. We'll compute the likelihood and the negative log likelihood."
], ],
"metadata": { "metadata": {
"id": "MvVX6tl9AEXF" "id": "MvVX6tl9AEXF"

View File

@@ -218,7 +218,7 @@
{ {
"cell_type": "markdown", "cell_type": "markdown",
"source": [ "source": [
"The left is model output and the right is the model output after the softmax has been applied, so it now lies in the range [0,1] and represents the probability, that y=0 (red), 1 (green) and 2 (blue) The dots at the bottom show the training data with the same color scheme. So we want the red curve to be high where there are red dots, the green curve to be high where there are green dotsmand the blue curve to be high where there are blue dots We'll compute the the likelihood and the negative log likelihood." "The left is model output and the right is the model output after the softmax has been applied, so it now lies in the range [0,1] and represents the probability, that y=0 (red), 1 (green) and 2 (blue) The dots at the bottom show the training data with the same color scheme. So we want the red curve to be high where there are red dots, the green curve to be high where there are green dotsmand the blue curve to be high where there are blue dots We'll compute the likelihood and the negative log likelihood."
], ],
"metadata": { "metadata": {
"id": "MvVX6tl9AEXF" "id": "MvVX6tl9AEXF"

View File

@@ -128,7 +128,7 @@
"\n", "\n",
"In part (b) of the practical we calculate the volume of a hypersphere of radius 0.5 (i.e., of diameter 1) as a function of the radius. You will find that the volume decreases to almost nothing in high dimensions. All of the volume is in the corners of the unit hypercube (which always has volume 1). Double weird.\n", "In part (b) of the practical we calculate the volume of a hypersphere of radius 0.5 (i.e., of diameter 1) as a function of the radius. You will find that the volume decreases to almost nothing in high dimensions. All of the volume is in the corners of the unit hypercube (which always has volume 1). Double weird.\n",
"\n", "\n",
"Note that you you can check your answer by doing the calculation for 2D using the standard formula for the area of a circle and making sure it matches." "Note that you can check your answer by doing the calculation for 2D using the standard formula for the area of a circle and making sure it matches."
], ],
"metadata": { "metadata": {
"id": "b2FYKV1SL4Z7" "id": "b2FYKV1SL4Z7"

View File

@@ -214,7 +214,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"# Compute the derivative of the the loss with respect to the function output f_val\n", "# Compute the derivative of the loss with respect to the function output f_val\n",
"def dl_df(f_val,y):\n", "def dl_df(f_val,y):\n",
" # Compute sigmoid of network output\n", " # Compute sigmoid of network output\n",
" sig_f_val = sig(f_val)\n", " sig_f_val = sig(f_val)\n",

View File

@@ -196,7 +196,7 @@
"source": [ "source": [
"# Visualizing the loss function\n", "# Visualizing the loss function\n",
"\n", "\n",
"The above process is equivalent to to descending coordinate wise on the loss function<br>\n", "The above process is equivalent to descending coordinate wise on the loss function<br>\n",
"\n", "\n",
"Now let's plot that function" "Now let's plot that function"
], ],

File diff suppressed because one or more lines are too long

View File

@@ -4,7 +4,6 @@
"metadata": { "metadata": {
"colab": { "colab": {
"provenance": [], "provenance": [],
"authorship_tag": "ABX9TyNioITtfAcfxEfM3UOfQyb9",
"include_colab_link": true "include_colab_link": true
}, },
"kernelspec": { "kernelspec": {
@@ -62,7 +61,7 @@
"source": [ "source": [
"The number of regions $N$ created by a shallow neural network with $D_i$ inputs and $D$ hidden units is given by Zaslavsky's formula:\n", "The number of regions $N$ created by a shallow neural network with $D_i$ inputs and $D$ hidden units is given by Zaslavsky's formula:\n",
"\n", "\n",
"\\begin{equation}N = \\sum_{j=0}^{D_{i}}\\binom{D}{j}=\\sum_{j=0}^{D_{i}} \\frac{D!}{(D-j)!j!} \\end{equation} <br>\n", "\\begin{equation}N = \\sum_{j=0}^{D_{i}}\\binom{D}{j}=\\sum_{j=0}^{D_{i}} \\frac{D!}{(D-j)!j!} \\end{equation} \n",
"\n" "\n"
], ],
"metadata": { "metadata": {
@@ -221,7 +220,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"# Now let's plot the graph from figure 3.9a (takes ~1min)\n", "# Now let's plot the graph from figure 3.9b (takes ~1min)\n",
"dims = np.array([1,5,10,50,100])\n", "dims = np.array([1,5,10,50,100])\n",
"regions = np.zeros((dims.shape[0], 200))\n", "regions = np.zeros((dims.shape[0], 200))\n",
"params = np.zeros((dims.shape[0], 200))\n", "params = np.zeros((dims.shape[0], 200))\n",

View File

@@ -169,7 +169,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"# Define parameters (note first dimension of theta and phi is padded to make indices match\n", "# Define parameters (note first dimension of theta and psi is padded to make indices match\n",
"# notation in book)\n", "# notation in book)\n",
"theta = np.zeros([4,2])\n", "theta = np.zeros([4,2])\n",
"psi = np.zeros([4,4])\n", "psi = np.zeros([4,4])\n",

View File

@@ -4,7 +4,6 @@
"metadata": { "metadata": {
"colab": { "colab": {
"provenance": [], "provenance": [],
"authorship_tag": "ABX9TyO2DaD75p+LGi7WgvTzjrk1",
"include_colab_link": true "include_colab_link": true
}, },
"kernelspec": { "kernelspec": {
@@ -31,7 +30,7 @@
"source": [ "source": [
"# **Notebook 4.3 Deep neural networks**\n", "# **Notebook 4.3 Deep neural networks**\n",
"\n", "\n",
"This network investigates converting neural networks to matrix form.\n", "This notebook investigates converting neural networks to matrix form.\n",
"\n", "\n",
"Work through the cells below, running each cell in turn. In various places you will see the words \"TODO\". Follow the instructions at these places and make predictions about what is going to happen or write code to complete the functions.\n", "Work through the cells below, running each cell in turn. In various places you will see the words \"TODO\". Follow the instructions at these places and make predictions about what is going to happen or write code to complete the functions.\n",
"\n", "\n",
@@ -150,7 +149,7 @@
{ {
"cell_type": "markdown", "cell_type": "markdown",
"source": [ "source": [
"Now we'll define the same neural network, but this time, we will use matrix form. When you get this right, it will draw the same plot as above." "Now we'll define the same neural network, but this time, we will use matrix form as in equation 4.15. When you get this right, it will draw the same plot as above."
], ],
"metadata": { "metadata": {
"id": "XCJqo_AjfAra" "id": "XCJqo_AjfAra"
@@ -176,8 +175,8 @@
"n1_in_mat = np.reshape(n1_in,(n_dim_in,n_data))\n", "n1_in_mat = np.reshape(n1_in,(n_dim_in,n_data))\n",
"\n", "\n",
"# This runs the network for ALL of the inputs, x at once so we can draw graph\n", "# This runs the network for ALL of the inputs, x at once so we can draw graph\n",
"h1 = ReLU(np.matmul(beta_0,np.ones((1,n_data))) + np.matmul(Omega_0,n1_in_mat))\n", "h1 = ReLU(beta_0 + np.matmul(Omega_0,n1_in_mat))\n",
"n1_out = np.matmul(beta_1,np.ones((1,n_data))) + np.matmul(Omega_1,h1)\n", "n1_out = beta_1 + np.matmul(Omega_1,h1)\n",
"\n", "\n",
"# Draw the network and check that it looks the same as the non-matrix case\n", "# Draw the network and check that it looks the same as the non-matrix case\n",
"plot_neural(n1_in, n1_out)" "plot_neural(n1_in, n1_out)"
@@ -247,9 +246,9 @@
"n1_in_mat = np.reshape(n1_in,(n_dim_in,n_data))\n", "n1_in_mat = np.reshape(n1_in,(n_dim_in,n_data))\n",
"\n", "\n",
"# This runs the network for ALL of the inputs, x at once so we can draw graph (hence extra np.ones term)\n", "# This runs the network for ALL of the inputs, x at once so we can draw graph (hence extra np.ones term)\n",
"h1 = ReLU(np.matmul(beta_0,np.ones((1,n_data))) + np.matmul(Omega_0,n1_in_mat))\n", "h1 = ReLU(beta_0 + np.matmul(Omega_0,n1_in_mat))\n",
"h2 = ReLU(np.matmul(beta_1,np.ones((1,n_data))) + np.matmul(Omega_1,h1))\n", "h2 = ReLU(beta_1 + np.matmul(Omega_1,h1))\n",
"n1_out = np.matmul(beta_2,np.ones((1,n_data))) + np.matmul(Omega_2,h2)\n", "n1_out = beta_2 + np.matmul(Omega_2,h2)\n",
"\n", "\n",
"# Draw the network and check that it looks the same as the non-matrix version\n", "# Draw the network and check that it looks the same as the non-matrix version\n",
"plot_neural(n1_in, n1_out)" "plot_neural(n1_in, n1_out)"
@@ -291,10 +290,10 @@
"\n", "\n",
"\n", "\n",
"# If you set the parameters to the correct sizes, the following code will run\n", "# If you set the parameters to the correct sizes, the following code will run\n",
"h1 = ReLU(np.matmul(beta_0,np.ones((1,n_data))) + np.matmul(Omega_0,x));\n", "h1 = ReLU(beta_0 + np.matmul(Omega_0,x));\n",
"h2 = ReLU(np.matmul(beta_1,np.ones((1,n_data))) + np.matmul(Omega_1,h1));\n", "h2 = ReLU(beta_1 + np.matmul(Omega_1,h1));\n",
"h3 = ReLU(np.matmul(beta_2,np.ones((1,n_data))) + np.matmul(Omega_2,h2));\n", "h3 = ReLU(beta_2 + np.matmul(Omega_2,h2));\n",
"y = np.matmul(beta_3,np.ones((1,n_data))) + np.matmul(Omega_3,h3)\n", "y = beta_3 + np.matmul(Omega_3,h3)\n",
"\n", "\n",
"if h1.shape[0] is not D_1 or h1.shape[1] is not n_data:\n", "if h1.shape[0] is not D_1 or h1.shape[1] is not n_data:\n",
" print(\"h1 is wrong shape\")\n", " print(\"h1 is wrong shape\")\n",

View File

@@ -211,7 +211,7 @@
"id": "MvVX6tl9AEXF" "id": "MvVX6tl9AEXF"
}, },
"source": [ "source": [
"The left is model output and the right is the model output after the softmax has been applied, so it now lies in the range [0,1] and represents the probability, that y=0 (red), 1 (green) and 2 (blue). The dots at the bottom show the training data with the same color scheme. So we want the red curve to be high where there are red dots, the green curve to be high where there are green dots, and the blue curve to be high where there are blue dots We'll compute the the likelihood and the negative log likelihood." "The left is model output and the right is the model output after the softmax has been applied, so it now lies in the range [0,1] and represents the probability, that y=0 (red), 1 (green) and 2 (blue). The dots at the bottom show the training data with the same color scheme. So we want the red curve to be high where there are red dots, the green curve to be high where there are green dots, and the blue curve to be high where there are blue dots We'll compute the likelihood and the negative log likelihood."
] ]
}, },
{ {
@@ -236,11 +236,10 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"# Let's double check we get the right answer before proceeding\n", "# Here are three examples\n",
"print(\"Correct answer = %3.3f, Your answer = %3.3f\"%(0.2,categorical_distribution(np.array([[0]]),np.array([[0.2],[0.5],[0.3]]))))\n", "print(categorical_distribution(np.array([[0]]),np.array([[0.2],[0.5],[0.3]])))\n",
"print(\"Correct answer = %3.3f, Your answer = %3.3f\"%(0.5,categorical_distribution(np.array([[1]]),np.array([[0.2],[0.5],[0.3]]))))\n", "print(categorical_distribution(np.array([[1]]),np.array([[0.2],[0.5],[0.3]])))\n",
"print(\"Correct answer = %3.3f, Your answer = %3.3f\"%(0.3,categorical_distribution(np.array([[2]]),np.array([[0.2],[0.5],[0.3]]))))\n", "print(categorical_distribution(np.array([[2]]),np.array([[0.2],[0.5],[0.3]])))"
"\n"
] ]
}, },
{ {

View File

@@ -130,7 +130,8 @@
"\n", "\n",
" print('Iter %d, a=%3.3f, b=%3.3f, c=%3.3f, d=%3.3f'%(n_iter, a,b,c,d))\n", " print('Iter %d, a=%3.3f, b=%3.3f, c=%3.3f, d=%3.3f'%(n_iter, a,b,c,d))\n",
"\n", "\n",
" # Rule #1 If the HEIGHT at point A is less than the HEIGHT at points B, C, and D then halve values of B, C, and D\n", " # Rule #1 If the HEIGHT at point A is less than the HEIGHT at points B, C, and D then move them to they are half\n",
" # as far from A as they start\n",
" # i.e. bring them closer to the original point\n", " # i.e. bring them closer to the original point\n",
" # TODO REPLACE THE BLOCK OF CODE BELOW WITH THIS RULE\n", " # TODO REPLACE THE BLOCK OF CODE BELOW WITH THIS RULE\n",
" if (0):\n", " if (0):\n",

View File

@@ -1,18 +1,16 @@
{ {
"cells": [ "cells": [
{ {
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"metadata": { "metadata": {
"colab_type": "text", "id": "view-in-github",
"id": "view-in-github" "colab_type": "text"
}, },
"source": [ "source": [
"<a href=\"https://colab.research.google.com/github/udlbook/udlbook/blob/main/Notebooks/Chap06/6_2_Gradient_Descent.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" "<a href=\"https://colab.research.google.com/github/udlbook/udlbook/blob/main/Notebooks/Chap06/6_2_Gradient_Descent.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
] ]
}, },
{ {
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"metadata": { "metadata": {
"id": "el8l05WQEO46" "id": "el8l05WQEO46"
@@ -111,7 +109,6 @@
] ]
}, },
{ {
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"metadata": { "metadata": {
"id": "QU5mdGvpTtEG" "id": "QU5mdGvpTtEG"
@@ -140,7 +137,6 @@
] ]
}, },
{ {
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"metadata": { "metadata": {
"id": "eB5DQvU5hYNx" "id": "eB5DQvU5hYNx"
@@ -162,7 +158,6 @@
] ]
}, },
{ {
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"metadata": { "metadata": {
"id": "F3trnavPiHpH" "id": "F3trnavPiHpH"
@@ -218,7 +213,6 @@
] ]
}, },
{ {
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"metadata": { "metadata": {
"id": "s9Duf05WqqSC" "id": "s9Duf05WqqSC"
@@ -252,7 +246,6 @@
] ]
}, },
{ {
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"metadata": { "metadata": {
"id": "RS1nEcYVuEAM" "id": "RS1nEcYVuEAM"
@@ -290,7 +283,6 @@
] ]
}, },
{ {
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"metadata": { "metadata": {
"id": "5EIjMM9Fw2eT" "id": "5EIjMM9Fw2eT"
@@ -333,11 +325,11 @@
" print('Iter %d, a=%3.3f, b=%3.3f, c=%3.3f, d=%3.3f'%(n_iter, a,b,c,d))\n", " print('Iter %d, a=%3.3f, b=%3.3f, c=%3.3f, d=%3.3f'%(n_iter, a,b,c,d))\n",
" print('a %f, b%f, c%f, d%f'%(lossa,lossb,lossc,lossd))\n", " print('a %f, b%f, c%f, d%f'%(lossa,lossb,lossc,lossd))\n",
"\n", "\n",
" # Rule #1 If point A is less than points B, C, and D then halve points B,C, and D\n", " # Rule #1 If point A is less than points B, C, and D then halve distance from A to points B,C, and D\n",
" if np.argmin((lossa,lossb,lossc,lossd))==0:\n", " if np.argmin((lossa,lossb,lossc,lossd))==0:\n",
" b = b/2\n", " b = a+ (b-a)/2\n",
" c = c/2\n", " c = a+ (c-a)/2\n",
" d = d/2\n", " d = a+ (d-a)/2\n",
" continue;\n", " continue;\n",
"\n", "\n",
" # Rule #2 If point b is less than point c then\n", " # Rule #2 If point b is less than point c then\n",
@@ -412,8 +404,8 @@
], ],
"metadata": { "metadata": {
"colab": { "colab": {
"include_colab_link": true, "provenance": [],
"provenance": [] "include_colab_link": true
}, },
"kernelspec": { "kernelspec": {
"display_name": "Python 3", "display_name": "Python 3",

View File

@@ -1,18 +1,16 @@
{ {
"cells": [ "cells": [
{ {
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"metadata": { "metadata": {
"colab_type": "text", "id": "view-in-github",
"id": "view-in-github" "colab_type": "text"
}, },
"source": [ "source": [
"<a href=\"https://colab.research.google.com/github/udlbook/udlbook/blob/main/Notebooks/Chap06/6_3_Stochastic_Gradient_Descent.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" "<a href=\"https://colab.research.google.com/github/udlbook/udlbook/blob/main/Notebooks/Chap06/6_3_Stochastic_Gradient_Descent.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
] ]
}, },
{ {
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"metadata": { "metadata": {
"id": "el8l05WQEO46" "id": "el8l05WQEO46"
@@ -122,7 +120,6 @@
] ]
}, },
{ {
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"metadata": { "metadata": {
"id": "QU5mdGvpTtEG" "id": "QU5mdGvpTtEG"
@@ -150,7 +147,6 @@
] ]
}, },
{ {
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"metadata": { "metadata": {
"id": "eB5DQvU5hYNx" "id": "eB5DQvU5hYNx"
@@ -172,7 +168,6 @@
] ]
}, },
{ {
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"metadata": { "metadata": {
"id": "F3trnavPiHpH" "id": "F3trnavPiHpH"
@@ -228,7 +223,6 @@
] ]
}, },
{ {
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"metadata": { "metadata": {
"id": "s9Duf05WqqSC" "id": "s9Duf05WqqSC"
@@ -279,7 +273,6 @@
] ]
}, },
{ {
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"metadata": { "metadata": {
"id": "RS1nEcYVuEAM" "id": "RS1nEcYVuEAM"
@@ -316,7 +309,6 @@
] ]
}, },
{ {
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"metadata": { "metadata": {
"id": "5EIjMM9Fw2eT" "id": "5EIjMM9Fw2eT"
@@ -359,11 +351,11 @@
" print('Iter %d, a=%3.3f, b=%3.3f, c=%3.3f, d=%3.3f'%(n_iter, a,b,c,d))\n", " print('Iter %d, a=%3.3f, b=%3.3f, c=%3.3f, d=%3.3f'%(n_iter, a,b,c,d))\n",
" print('a %f, b%f, c%f, d%f'%(lossa,lossb,lossc,lossd))\n", " print('a %f, b%f, c%f, d%f'%(lossa,lossb,lossc,lossd))\n",
"\n", "\n",
" # Rule #1 If point A is less than points B, C, and D then halve points B,C, and D\n", " # Rule #1 If point A is less than points B, C, and D then change B,C,D so they are half their current distance from A\n",
" if np.argmin((lossa,lossb,lossc,lossd))==0:\n", " if np.argmin((lossa,lossb,lossc,lossd))==0:\n",
" b = b/2\n", " b = a+ (b-a)/2\n",
" c = c/2\n", " c = a+ (c-a)/2\n",
" d = d/2\n", " d = a+ (d-a)/2\n",
" continue;\n", " continue;\n",
"\n", "\n",
" # Rule #2 If point b is less than point c then\n", " # Rule #2 If point b is less than point c then\n",
@@ -577,9 +569,8 @@
], ],
"metadata": { "metadata": {
"colab": { "colab": {
"authorship_tag": "ABX9TyNk5FN4qlw3pk8BwDVWw1jN", "provenance": [],
"include_colab_link": true, "include_colab_link": true
"provenance": []
}, },
"kernelspec": { "kernelspec": {
"display_name": "Python 3", "display_name": "Python 3",

View File

@@ -221,7 +221,7 @@
{ {
"cell_type": "markdown", "cell_type": "markdown",
"source": [ "source": [
"This moves towards the minimum at a sensible speed, but we never actually converge -- the solution just bounces back and forth between the last two points. To make it converge, we add momentum to both the estimates of the gradient and the pointwise squared gradient. We also modify the statistics by a factor that depends on the time to make sure the progress is now slow to start with." "This moves towards the minimum at a sensible speed, but we never actually converge -- the solution just bounces back and forth between the last two points. To make it converge, we add momentum to both the estimates of the gradient and the pointwise squared gradient. We also modify the statistics by a factor that depends on the time to make sure the progress is not slow to start with."
], ],
"metadata": { "metadata": {
"id": "_6KoKBJdGGI4" "id": "_6KoKBJdGGI4"

View File

@@ -4,7 +4,6 @@
"metadata": { "metadata": {
"colab": { "colab": {
"provenance": [], "provenance": [],
"authorship_tag": "ABX9TyM2kkHLr00J4Jeypw41sTkQ",
"include_colab_link": true "include_colab_link": true
}, },
"kernelspec": { "kernelspec": {
@@ -68,7 +67,7 @@
"# Set seed so we always get the same random numbers\n", "# Set seed so we always get the same random numbers\n",
"np.random.seed(0)\n", "np.random.seed(0)\n",
"\n", "\n",
"# Number of layers\n", "# Number of hidden layers\n",
"K = 5\n", "K = 5\n",
"# Number of neurons per layer\n", "# Number of neurons per layer\n",
"D = 6\n", "D = 6\n",
@@ -115,7 +114,7 @@
{ {
"cell_type": "markdown", "cell_type": "markdown",
"source": [ "source": [
"Now let's run our random network. The weight matrices $\\boldsymbol\\Omega_{1\\ldots K}$ are the entries of the list \"all_weights\" and the biases $\\boldsymbol\\beta_{1\\ldots K}$ are the entries of the list \"all_biases\"\n", "Now let's run our random network. The weight matrices $\\boldsymbol\\Omega_{0\\ldots K}$ are the entries of the list \"all_weights\" and the biases $\\boldsymbol\\beta_{0\\ldots K}$ are the entries of the list \"all_biases\"\n",
"\n", "\n",
"We know that we will need the preactivations $\\mathbf{f}_{0\\ldots K}$ and the activations $\\mathbf{h}_{1\\ldots K}$ for the forward pass of backpropagation, so we'll store and return these as well.\n" "We know that we will need the preactivations $\\mathbf{f}_{0\\ldots K}$ and the activations $\\mathbf{h}_{1\\ldots K}$ for the forward pass of backpropagation, so we'll store and return these as well.\n"
], ],
@@ -142,8 +141,8 @@
"\n", "\n",
" # Run through the layers, calculating all_f[0...K-1] and all_h[1...K]\n", " # Run through the layers, calculating all_f[0...K-1] and all_h[1...K]\n",
" for layer in range(K):\n", " for layer in range(K):\n",
" # Update preactivations and activations at this layer according to eqn 7.16\n", " # Update preactivations and activations at this layer according to eqn 7.17\n",
" # Remmember to use np.matmul for matrix multiplications\n", " # Remember to use np.matmul for matrix multiplications\n",
" # TODO -- Replace the lines below\n", " # TODO -- Replace the lines below\n",
" all_f[layer] = all_h[layer]\n", " all_f[layer] = all_h[layer]\n",
" all_h[layer+1] = all_f[layer]\n", " all_h[layer+1] = all_f[layer]\n",
@@ -230,8 +229,8 @@
"# We'll need the indicator function\n", "# We'll need the indicator function\n",
"def indicator_function(x):\n", "def indicator_function(x):\n",
" x_in = np.array(x)\n", " x_in = np.array(x)\n",
" x_in[x_in>=0] = 1\n", " x_in[x_in>0] = 1\n",
" x_in[x_in<0] = 0\n", " x_in[x_in<=0] = 0\n",
" return x_in\n", " return x_in\n",
"\n", "\n",
"# Main backward pass routine\n", "# Main backward pass routine\n",
@@ -249,23 +248,23 @@
"\n", "\n",
" # Now work backwards through the network\n", " # Now work backwards through the network\n",
" for layer in range(K,-1,-1):\n", " for layer in range(K,-1,-1):\n",
" # TODO Calculate the derivatives of the loss with respect to the biases at layer from all_dl_df[layer]. (eq 7.21)\n", " # TODO Calculate the derivatives of the loss with respect to the biases at layer from all_dl_df[layer]. (eq 7.22)\n",
" # NOTE! To take a copy of matrix X, use Z=np.array(X)\n", " # NOTE! To take a copy of matrix X, use Z=np.array(X)\n",
" # REPLACE THIS LINE\n", " # REPLACE THIS LINE\n",
" all_dl_dbiases[layer] = np.zeros_like(all_biases[layer])\n", " all_dl_dbiases[layer] = np.zeros_like(all_biases[layer])\n",
"\n", "\n",
" # TODO Calculate the derivatives of the loss with respect to the weights at layer from all_dl_df[layer] and all_h[layer] (eq 7.22)\n", " # TODO Calculate the derivatives of the loss with respect to the weights at layer from all_dl_df[layer] and all_h[layer] (eq 7.23)\n",
" # Don't forget to use np.matmul\n", " # Don't forget to use np.matmul\n",
" # REPLACE THIS LINE\n", " # REPLACE THIS LINE\n",
" all_dl_dweights[layer] = np.zeros_like(all_weights[layer])\n", " all_dl_dweights[layer] = np.zeros_like(all_weights[layer])\n",
"\n", "\n",
" # TODO: calculate the derivatives of the loss with respect to the activations from weight and derivatives of next preactivations (second part of last line of eq 7.24)\n", " # TODO: calculate the derivatives of the loss with respect to the activations from weight and derivatives of next preactivations (second part of last line of eq 7.25)\n",
" # REPLACE THIS LINE\n", " # REPLACE THIS LINE\n",
" all_dl_dh[layer] = np.zeros_like(all_h[layer])\n", " all_dl_dh[layer] = np.zeros_like(all_h[layer])\n",
"\n", "\n",
"\n", "\n",
" if layer > 0:\n", " if layer > 0:\n",
" # TODO Calculate the derivatives of the loss with respect to the pre-activation f (use derivative of ReLu function, first part of last line of eq. 7.24)\n", " # TODO Calculate the derivatives of the loss with respect to the pre-activation f (use derivative of ReLu function, first part of last line of eq. 7.25)\n",
" # REPLACE THIS LINE\n", " # REPLACE THIS LINE\n",
" all_dl_df[layer-1] = np.zeros_like(all_f[layer-1])\n", " all_dl_df[layer-1] = np.zeros_like(all_f[layer-1])\n",
"\n", "\n",
@@ -300,7 +299,7 @@
"delta_fd = 0.000001\n", "delta_fd = 0.000001\n",
"\n", "\n",
"# Test the dervatives of the bias vectors\n", "# Test the dervatives of the bias vectors\n",
"for layer in range(K):\n", "for layer in range(K+1):\n",
" dl_dbias = np.zeros_like(all_dl_dbiases[layer])\n", " dl_dbias = np.zeros_like(all_dl_dbiases[layer])\n",
" # For every element in the bias\n", " # For every element in the bias\n",
" for row in range(all_biases[layer].shape[0]):\n", " for row in range(all_biases[layer].shape[0]):\n",
@@ -324,7 +323,7 @@
"\n", "\n",
"\n", "\n",
"# Test the derivatives of the weights matrices\n", "# Test the derivatives of the weights matrices\n",
"for layer in range(K):\n", "for layer in range(K+1):\n",
" dl_dweight = np.zeros_like(all_dl_dweights[layer])\n", " dl_dweight = np.zeros_like(all_dl_dweights[layer])\n",
" # For every element in the bias\n", " # For every element in the bias\n",
" for row in range(all_weights[layer].shape[0]):\n", " for row in range(all_weights[layer].shape[0]):\n",

View File

@@ -4,7 +4,6 @@
"metadata": { "metadata": {
"colab": { "colab": {
"provenance": [], "provenance": [],
"authorship_tag": "ABX9TyOaATWBrwVMylV1akcKtHjt",
"include_colab_link": true "include_colab_link": true
}, },
"kernelspec": { "kernelspec": {
@@ -250,7 +249,7 @@
"# Main backward pass routine\n", "# Main backward pass routine\n",
"def backward_pass(all_weights, all_biases, all_f, all_h, y):\n", "def backward_pass(all_weights, all_biases, all_f, all_h, y):\n",
" # Retrieve number of layers\n", " # Retrieve number of layers\n",
" K = all_weights\n", " K = len(all_weights) - 1\n",
"\n", "\n",
" # We'll store the derivatives dl_dweights and dl_dbiases in lists as well\n", " # We'll store the derivatives dl_dweights and dl_dbiases in lists as well\n",
" all_dl_dweights = [None] * (K+1)\n", " all_dl_dweights = [None] * (K+1)\n",
@@ -338,8 +337,8 @@
{ {
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"# You can see that the values of the hidden units are increasing on average (the variance is across all hidden units at the layer\n", "# You can see that the gradients of the hidden units are increasing on average (the standard deviation is across all hidden units at the layer\n",
"# and the 1000 training examples\n", "# and the 100 training examples\n",
"\n", "\n",
"# TODO\n", "# TODO\n",
"# Change this to 50 layers with 80 hidden units per layer\n", "# Change this to 50 layers with 80 hidden units per layer\n",

View File

@@ -1,28 +1,10 @@
{ {
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"provenance": [],
"gpuType": "T4",
"authorship_tag": "ABX9TyOuKMUcKfOIhIL2qTX9jJCy",
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
},
"language_info": {
"name": "python"
},
"accelerator": "GPU"
},
"cells": [ "cells": [
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": { "metadata": {
"id": "view-in-github", "colab_type": "text",
"colab_type": "text" "id": "view-in-github"
}, },
"source": [ "source": [
"<a href=\"https://colab.research.google.com/github/udlbook/udlbook/blob/main/Notebooks/Chap08/8_1_MNIST_1D_Performance.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" "<a href=\"https://colab.research.google.com/github/udlbook/udlbook/blob/main/Notebooks/Chap08/8_1_MNIST_1D_Performance.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
@@ -30,6 +12,9 @@
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {
"id": "L6chybAVFJW2"
},
"source": [ "source": [
"# **Notebook 8.1: MNIST_1D_Performance**\n", "# **Notebook 8.1: MNIST_1D_Performance**\n",
"\n", "\n",
@@ -38,25 +23,27 @@
"Work through the cells below, running each cell in turn. In various places you will see the words \"TODO\". Follow the instructions at these places and make predictions about what is going to happen or write code to complete the functions.\n", "Work through the cells below, running each cell in turn. In various places you will see the words \"TODO\". Follow the instructions at these places and make predictions about what is going to happen or write code to complete the functions.\n",
"\n", "\n",
"Contact me at udlbookmail@gmail.com if you find any mistakes or have any suggestions." "Contact me at udlbookmail@gmail.com if you find any mistakes or have any suggestions."
], ]
"metadata": {
"id": "L6chybAVFJW2"
}
}, },
{ {
"cell_type": "code", "cell_type": "code",
"source": [ "execution_count": null,
"# Run this if you're in a Colab to make a local copy of the MNIST 1D repository\n",
"!git clone https://github.com/greydanus/mnist1d"
],
"metadata": { "metadata": {
"id": "ifVjS4cTOqKz" "id": "ifVjS4cTOqKz"
}, },
"execution_count": null, "outputs": [],
"outputs": [] "source": [
"# Run this if you're in a Colab to install MNIST 1D repository\n",
"%pip install git+https://github.com/greydanus/mnist1d"
]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null,
"metadata": {
"id": "qyE7G1StPIqO"
},
"outputs": [],
"source": [ "source": [
"import torch, torch.nn as nn\n", "import torch, torch.nn as nn\n",
"from torch.utils.data import TensorDataset, DataLoader\n", "from torch.utils.data import TensorDataset, DataLoader\n",
@@ -64,44 +51,42 @@
"import numpy as np\n", "import numpy as np\n",
"import matplotlib.pyplot as plt\n", "import matplotlib.pyplot as plt\n",
"import mnist1d" "import mnist1d"
], ]
"metadata": {
"id": "qyE7G1StPIqO"
},
"execution_count": null,
"outputs": []
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"source": [
"Let's generate a training and test dataset using the MNIST1D code. The dataset gets saved as a .pkl file so it doesn't have to be regenerated each time."
],
"metadata": { "metadata": {
"id": "F7LNq72SP6jO" "id": "F7LNq72SP6jO"
} },
"source": [
"Let's generate a training and test dataset using the MNIST1D code. The dataset gets saved as a .pkl file so it doesn't have to be regenerated each time."
]
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null,
"metadata": {
"id": "YLxf7dJfPaqw"
},
"outputs": [],
"source": [ "source": [
"!mkdir ./sample_data\n",
"\n",
"args = mnist1d.data.get_dataset_args()\n", "args = mnist1d.data.get_dataset_args()\n",
"data = mnist1d.data.get_dataset(args, path='./sample_data/mnist1d_data.pkl', download=False, regenerate=False)\n", "data = mnist1d.data.get_dataset(args, path='./mnist1d_data.pkl', download=False, regenerate=False)\n",
"\n", "\n",
"# The training and test input and outputs are in\n", "# The training and test input and outputs are in\n",
"# data['x'], data['y'], data['x_test'], and data['y_test']\n", "# data['x'], data['y'], data['x_test'], and data['y_test']\n",
"print(\"Examples in training set: {}\".format(len(data['y'])))\n", "print(\"Examples in training set: {}\".format(len(data['y'])))\n",
"print(\"Examples in test set: {}\".format(len(data['y_test'])))\n", "print(\"Examples in test set: {}\".format(len(data['y_test'])))\n",
"print(\"Length of each example: {}\".format(data['x'].shape[-1]))" "print(\"Length of each example: {}\".format(data['x'].shape[-1]))"
], ]
"metadata": {
"id": "YLxf7dJfPaqw"
},
"execution_count": null,
"outputs": []
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null,
"metadata": {
"id": "FxaB5vc0uevl"
},
"outputs": [],
"source": [ "source": [
"D_i = 40 # Input dimensions\n", "D_i = 40 # Input dimensions\n",
"D_k = 100 # Hidden dimensions\n", "D_k = 100 # Hidden dimensions\n",
@@ -122,15 +107,15 @@
"\n", "\n",
"# Call the function you just defined\n", "# Call the function you just defined\n",
"model.apply(weights_init)\n" "model.apply(weights_init)\n"
], ]
"metadata": {
"id": "FxaB5vc0uevl"
},
"execution_count": null,
"outputs": []
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null,
"metadata": {
"id": "_rX6N3VyyQTY"
},
"outputs": [],
"source": [ "source": [
"# choose cross entropy loss function (equation 5.24)\n", "# choose cross entropy loss function (equation 5.24)\n",
"loss_function = torch.nn.CrossEntropyLoss()\n", "loss_function = torch.nn.CrossEntropyLoss()\n",
@@ -139,9 +124,9 @@
"# object that decreases learning rate by half every 10 epochs\n", "# object that decreases learning rate by half every 10 epochs\n",
"scheduler = StepLR(optimizer, step_size=10, gamma=0.5)\n", "scheduler = StepLR(optimizer, step_size=10, gamma=0.5)\n",
"x_train = torch.tensor(data['x'].astype('float32'))\n", "x_train = torch.tensor(data['x'].astype('float32'))\n",
"y_train = torch.tensor(data['y'].transpose().astype('long'))\n", "y_train = torch.tensor(data['y'].transpose().astype('int64'))\n",
"x_test= torch.tensor(data['x_test'].astype('float32'))\n", "x_test= torch.tensor(data['x_test'].astype('float32'))\n",
"y_test = torch.tensor(data['y_test'].astype('long'))\n", "y_test = torch.tensor(data['y_test'].astype('int64'))\n",
"\n", "\n",
"# load the data into a class that creates the batches\n", "# load the data into a class that creates the batches\n",
"data_loader = DataLoader(TensorDataset(x_train,y_train), batch_size=100, shuffle=True, worker_init_fn=np.random.seed(1))\n", "data_loader = DataLoader(TensorDataset(x_train,y_train), batch_size=100, shuffle=True, worker_init_fn=np.random.seed(1))\n",
@@ -186,15 +171,15 @@
"\n", "\n",
" # tell scheduler to consider updating learning rate\n", " # tell scheduler to consider updating learning rate\n",
" scheduler.step()" " scheduler.step()"
], ]
"metadata": {
"id": "_rX6N3VyyQTY"
},
"execution_count": null,
"outputs": []
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null,
"metadata": {
"id": "yI-l6kA_EH9G"
},
"outputs": [],
"source": [ "source": [
"# Plot the results\n", "# Plot the results\n",
"fig, ax = plt.subplots()\n", "fig, ax = plt.subplots()\n",
@@ -215,25 +200,38 @@
"ax.set_title('Train loss %3.2f, Test loss %3.2f'%(losses_train[-1],losses_test[-1]))\n", "ax.set_title('Train loss %3.2f, Test loss %3.2f'%(losses_train[-1],losses_test[-1]))\n",
"ax.legend()\n", "ax.legend()\n",
"plt.show()" "plt.show()"
], ]
"metadata": {
"id": "yI-l6kA_EH9G"
},
"execution_count": null,
"outputs": []
}, },
{ {
"cell_type": "markdown", "cell_type": "markdown",
"metadata": {
"id": "q-yT6re6GZS4"
},
"source": [ "source": [
"**TODO**\n", "**TODO**\n",
"\n", "\n",
"Play with the model -- try changing the number of layers, hidden units, learning rate, batch size, momentum or anything else you like. See if you can improve the test results.\n", "Play with the model -- try changing the number of layers, hidden units, learning rate, batch size, momentum or anything else you like. See if you can improve the test results.\n",
"\n", "\n",
"Is it a good idea to optimize the hyperparameters in this way? Will the final result be a good estimate of the true test performance?" "Is it a good idea to optimize the hyperparameters in this way? Will the final result be a good estimate of the true test performance?"
],
"metadata": {
"id": "q-yT6re6GZS4"
}
}
] ]
} }
],
"metadata": {
"accelerator": "GPU",
"colab": {
"authorship_tag": "ABX9TyOuKMUcKfOIhIL2qTX9jJCy",
"gpuType": "T4",
"include_colab_link": true,
"provenance": []
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
},
"language_info": {
"name": "python"
}
},
"nbformat": 4,
"nbformat_minor": 0
}

View File

@@ -5,7 +5,6 @@
"colab": { "colab": {
"provenance": [], "provenance": [],
"gpuType": "T4", "gpuType": "T4",
"authorship_tag": "ABX9TyN/KUpEObCKnHZ/4Onp5sHG",
"include_colab_link": true "include_colab_link": true
}, },
"kernelspec": { "kernelspec": {
@@ -48,8 +47,8 @@
{ {
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"# Run this if you're in a Colab to make a local copy of the MNIST 1D repository\n", "# Run this if you're in a Colab to install MNIST 1D repository\n",
"!git clone https://github.com/greydanus/mnist1d" "!pip install git+https://github.com/greydanus/mnist1d"
], ],
"metadata": { "metadata": {
"id": "fn9BP5N5TguP" "id": "fn9BP5N5TguP"
@@ -100,7 +99,7 @@
"# data['x'], data['y'], data['x_test'], and data['y_test']\n", "# data['x'], data['y'], data['x_test'], and data['y_test']\n",
"print(\"Examples in training set: {}\".format(len(data['y'])))\n", "print(\"Examples in training set: {}\".format(len(data['y'])))\n",
"print(\"Examples in test set: {}\".format(len(data['y_test'])))\n", "print(\"Examples in test set: {}\".format(len(data['y_test'])))\n",
"print(\"Length of each example: {}\".format(data['x'].shape[-1]))" "print(\"Dimensionality of each example: {}\".format(data['x'].shape[-1]))"
], ],
"metadata": { "metadata": {
"id": "PW2gyXL5UkLU" "id": "PW2gyXL5UkLU"
@@ -148,7 +147,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"def fit_model(model, data):\n", "def fit_model(model, data, n_epoch):\n",
"\n", "\n",
" # choose cross entropy loss function (equation 5.24)\n", " # choose cross entropy loss function (equation 5.24)\n",
" loss_function = torch.nn.CrossEntropyLoss()\n", " loss_function = torch.nn.CrossEntropyLoss()\n",
@@ -165,9 +164,6 @@
" # load the data into a class that creates the batches\n", " # load the data into a class that creates the batches\n",
" data_loader = DataLoader(TensorDataset(x_train,y_train), batch_size=100, shuffle=True, worker_init_fn=np.random.seed(1))\n", " data_loader = DataLoader(TensorDataset(x_train,y_train), batch_size=100, shuffle=True, worker_init_fn=np.random.seed(1))\n",
"\n", "\n",
" # loop over the dataset n_epoch times\n",
" n_epoch = 1000\n",
"\n",
" for epoch in range(n_epoch):\n", " for epoch in range(n_epoch):\n",
" # loop over batches\n", " # loop over batches\n",
" for i, batch in enumerate(data_loader):\n", " for i, batch in enumerate(data_loader):\n",
@@ -204,6 +200,18 @@
"execution_count": null, "execution_count": null,
"outputs": [] "outputs": []
}, },
{
"cell_type": "code",
"source": [
"def count_parameters(model):\n",
" return sum(p.numel() for p in model.parameters() if p.requires_grad)"
],
"metadata": {
"id": "AQNCmFNV6JpV"
},
"execution_count": null,
"outputs": []
},
{ {
"cell_type": "markdown", "cell_type": "markdown",
"source": [ "source": [
@@ -227,19 +235,27 @@
"# This code will take a while (~30 mins on GPU) to run! Go and make a cup of coffee!\n", "# This code will take a while (~30 mins on GPU) to run! Go and make a cup of coffee!\n",
"\n", "\n",
"hidden_variables = np.array([2,4,6,8,10,14,18,22,26,30,35,40,45,50,55,60,70,80,90,100,120,140,160,180,200,250,300,400]) ;\n", "hidden_variables = np.array([2,4,6,8,10,14,18,22,26,30,35,40,45,50,55,60,70,80,90,100,120,140,160,180,200,250,300,400]) ;\n",
"\n",
"errors_train_all = np.zeros_like(hidden_variables)\n", "errors_train_all = np.zeros_like(hidden_variables)\n",
"errors_test_all = np.zeros_like(hidden_variables)\n", "errors_test_all = np.zeros_like(hidden_variables)\n",
"total_weights_all = np.zeros_like(hidden_variables)\n",
"\n",
"# loop over the dataset n_epoch times\n",
"n_epoch = 1000\n",
"\n", "\n",
"# For each hidden variable size\n", "# For each hidden variable size\n",
"for c_hidden in range(len(hidden_variables)):\n", "for c_hidden in range(len(hidden_variables)):\n",
" print(f'Training model with {hidden_variables[c_hidden]:3d} hidden variables')\n", " print(f'Training model with {hidden_variables[c_hidden]:3d} hidden variables')\n",
" # Get a model\n", " # Get a model\n",
" model = get_model(hidden_variables[c_hidden]) ;\n", " model = get_model(hidden_variables[c_hidden]) ;\n",
" # Count and store number of weights\n",
" total_weights_all[c_hidden] = count_parameters(model)\n",
" # Train the model\n", " # Train the model\n",
" errors_train, errors_test = fit_model(model, data)\n", " errors_train, errors_test = fit_model(model, data, n_epoch)\n",
" # Store the results\n", " # Store the results\n",
" errors_train_all[c_hidden] = errors_train\n", " errors_train_all[c_hidden] = errors_train\n",
" errors_test_all[c_hidden]= errors_test" " errors_test_all[c_hidden]= errors_test\n",
"\n"
], ],
"metadata": { "metadata": {
"id": "K4OmBZGHWXpk" "id": "K4OmBZGHWXpk"
@@ -250,12 +266,29 @@
{ {
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
"# Assuming data['y'] is available and contains the training examples\n",
"num_training_examples = len(data['y'])\n",
"\n",
"# Find the index where total_weights_all is closest to num_training_examples\n",
"closest_index = np.argmin(np.abs(np.array(total_weights_all) - num_training_examples))\n",
"\n",
"# Get the corresponding value of hidden variables\n",
"hidden_variable_at_num_training_examples = hidden_variables[closest_index]\n",
"\n",
"# Plot the results\n", "# Plot the results\n",
"fig, ax = plt.subplots()\n", "fig, ax = plt.subplots()\n",
"ax.plot(hidden_variables, errors_train_all, 'r-', label='train')\n", "ax.plot(hidden_variables, errors_train_all, 'r-', label='train')\n",
"ax.plot(hidden_variables, errors_test_all, 'b-', label='test')\n", "ax.plot(hidden_variables, errors_test_all, 'b-', label='test')\n",
"ax.set_ylim(0,100);\n", "\n",
"ax.set_xlabel('No hidden variables'); ax.set_ylabel('Error')\n", "# Add a vertical line at the point where total weights equal the number of training examples\n",
"ax.axvline(x=hidden_variable_at_num_training_examples, color='g', linestyle='--', label='N(weights) = N(train)')\n",
"\n",
"ax.set_ylim(0, 100)\n",
"ax.set_xlabel('No. hidden variables')\n",
"ax.set_ylabel('Error')\n",
"ax.legend()\n", "ax.legend()\n",
"plt.show()\n" "plt.show()\n"
], ],
@@ -264,6 +297,24 @@
}, },
"execution_count": null, "execution_count": null,
"outputs": [] "outputs": []
},
{
"cell_type": "code",
"source": [],
"metadata": {
"id": "KT4X8_hE5NFb"
},
"execution_count": null,
"outputs": []
},
{
"cell_type": "code",
"source": [],
"metadata": {
"id": "iGKZSfVF2r4z"
},
"execution_count": null,
"outputs": []
} }
] ]
} }

View File

@@ -134,7 +134,7 @@
"source": [ "source": [
"# Volume of a hypersphere\n", "# Volume of a hypersphere\n",
"\n", "\n",
"In the second part of this notebook we calculate the volume of a hypersphere of radius 0.5 (i.e., of diameter 1) as a function of the radius. Note that you you can check your answer by doing the calculation for 2D using the standard formula for the area of a circle and making sure it matches." "In the second part of this notebook we calculate the volume of a hypersphere of radius 0.5 (i.e., of diameter 1) as a function of the radius. Note that you can check your answer by doing the calculation for 2D using the standard formula for the area of a circle and making sure it matches."
], ],
"metadata": { "metadata": {
"id": "b2FYKV1SL4Z7" "id": "b2FYKV1SL4Z7"

View File

@@ -178,7 +178,7 @@
"\n", "\n",
"def draw_loss_function(compute_loss, data, model, my_colormap, phi_iters = None):\n", "def draw_loss_function(compute_loss, data, model, my_colormap, phi_iters = None):\n",
"\n", "\n",
" # Make grid of intercept/slope values to plot\n", " # Make grid of offset/frequency values to plot\n",
" offsets_mesh, freqs_mesh = np.meshgrid(np.arange(-10,10.0,0.1), np.arange(2.5,22.5,0.1))\n", " offsets_mesh, freqs_mesh = np.meshgrid(np.arange(-10,10.0,0.1), np.arange(2.5,22.5,0.1))\n",
" loss_mesh = np.zeros_like(freqs_mesh)\n", " loss_mesh = np.zeros_like(freqs_mesh)\n",
" # Compute loss for every set of parameters\n", " # Compute loss for every set of parameters\n",
@@ -304,7 +304,7 @@
"for c_step in range (n_steps):\n", "for c_step in range (n_steps):\n",
" # Do gradient descent step\n", " # Do gradient descent step\n",
" phi_all[:,c_step+1:c_step+2] = gradient_descent_step(phi_all[:,c_step:c_step+1],data, model)\n", " phi_all[:,c_step+1:c_step+2] = gradient_descent_step(phi_all[:,c_step:c_step+1],data, model)\n",
" # Measure loss and draw model every 4th step\n", " # Measure loss and draw model every 8th step\n",
" if c_step % 8 == 0:\n", " if c_step % 8 == 0:\n",
" loss = compute_loss(data[0,:], data[1,:], model, phi_all[:,c_step+1:c_step+2])\n", " loss = compute_loss(data[0,:], data[1,:], model, phi_all[:,c_step+1:c_step+2])\n",
" draw_model(data,model,phi_all[:,c_step+1], \"Iteration %d, loss = %f\"%(c_step+1,loss))\n", " draw_model(data,model,phi_all[:,c_step+1], \"Iteration %d, loss = %f\"%(c_step+1,loss))\n",
@@ -369,7 +369,7 @@
"# Code to draw the regularization function\n", "# Code to draw the regularization function\n",
"def draw_reg_function():\n", "def draw_reg_function():\n",
"\n", "\n",
" # Make grid of intercept/slope values to plot\n", " # Make grid of offset/frequency values to plot\n",
" offsets_mesh, freqs_mesh = np.meshgrid(np.arange(-10,10.0,0.1), np.arange(2.5,22.5,0.1))\n", " offsets_mesh, freqs_mesh = np.meshgrid(np.arange(-10,10.0,0.1), np.arange(2.5,22.5,0.1))\n",
" loss_mesh = np.zeros_like(freqs_mesh)\n", " loss_mesh = np.zeros_like(freqs_mesh)\n",
" # Compute loss for every set of parameters\n", " # Compute loss for every set of parameters\n",
@@ -399,7 +399,7 @@
"# Code to draw loss function with regularization\n", "# Code to draw loss function with regularization\n",
"def draw_loss_function_reg(data, model, lambda_, my_colormap, phi_iters = None):\n", "def draw_loss_function_reg(data, model, lambda_, my_colormap, phi_iters = None):\n",
"\n", "\n",
" # Make grid of intercept/slope values to plot\n", " # Make grid of offset/frequency values to plot\n",
" offsets_mesh, freqs_mesh = np.meshgrid(np.arange(-10,10.0,0.1), np.arange(2.5,22.5,0.1))\n", " offsets_mesh, freqs_mesh = np.meshgrid(np.arange(-10,10.0,0.1), np.arange(2.5,22.5,0.1))\n",
" loss_mesh = np.zeros_like(freqs_mesh)\n", " loss_mesh = np.zeros_like(freqs_mesh)\n",
" # Compute loss for every set of parameters\n", " # Compute loss for every set of parameters\n",
@@ -512,7 +512,7 @@
"for c_step in range (n_steps):\n", "for c_step in range (n_steps):\n",
" # Do gradient descent step\n", " # Do gradient descent step\n",
" phi_all[:,c_step+1:c_step+2] = gradient_descent_step2(phi_all[:,c_step:c_step+1],lambda_, data, model)\n", " phi_all[:,c_step+1:c_step+2] = gradient_descent_step2(phi_all[:,c_step:c_step+1],lambda_, data, model)\n",
" # Measure loss and draw model every 4th step\n", " # Measure loss and draw model every 8th step\n",
" if c_step % 8 == 0:\n", " if c_step % 8 == 0:\n",
" loss = compute_loss2(data[0,:], data[1,:], model, phi_all[:,c_step+1:c_step+2], lambda_)\n", " loss = compute_loss2(data[0,:], data[1,:], model, phi_all[:,c_step+1:c_step+2], lambda_)\n",
" draw_model(data,model,phi_all[:,c_step+1], \"Iteration %d, loss = %f\"%(c_step+1,loss))\n", " draw_model(data,model,phi_all[:,c_step+1], \"Iteration %d, loss = %f\"%(c_step+1,loss))\n",
@@ -528,7 +528,7 @@
{ {
"cell_type": "markdown", "cell_type": "markdown",
"source": [ "source": [
"You should see that the gradient descent algorithm now finds the correct minimum. By applying a tiny bit of domain knowledge (the parameter phi0 tends to be near zero and the parameters phi1 tends to be near 12.5), we get a better solution. However, the cost is that this solution is slightly biased towards this prior knowledge." "You should see that the gradient descent algorithm now finds the correct minimum. By applying a tiny bit of domain knowledge (the parameter phi0 tends to be near zero and the parameter phi1 tends to be near 12.5), we get a better solution. However, the cost is that this solution is slightly biased towards this prior knowledge."
], ],
"metadata": { "metadata": {
"id": "wrszSLrqZG4k" "id": "wrszSLrqZG4k"

View File

@@ -52,7 +52,7 @@
"# import libraries\n", "# import libraries\n",
"import numpy as np\n", "import numpy as np\n",
"import matplotlib.pyplot as plt\n", "import matplotlib.pyplot as plt\n",
"# Define seed so get same results each time\n", "# Define seed to get same results each time\n",
"np.random.seed(1)" "np.random.seed(1)"
] ]
}, },
@@ -80,7 +80,7 @@
" for i in range(n_data):\n", " for i in range(n_data):\n",
" x[i] = np.random.uniform(i/n_data, (i+1)/n_data, 1)\n", " x[i] = np.random.uniform(i/n_data, (i+1)/n_data, 1)\n",
"\n", "\n",
" # y value from running through functoin and adding noise\n", " # y value from running through function and adding noise\n",
" y = np.ones(n_data)\n", " y = np.ones(n_data)\n",
" for i in range(n_data):\n", " for i in range(n_data):\n",
" y[i] = true_function(x[i])\n", " y[i] = true_function(x[i])\n",
@@ -96,7 +96,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"# Draw the fitted function, together win uncertainty used to generate points\n", "# Draw the fitted function, together with uncertainty used to generate points\n",
"def plot_function(x_func, y_func, x_data=None,y_data=None, x_model = None, y_model =None, sigma_func = None, sigma_model=None):\n", "def plot_function(x_func, y_func, x_data=None,y_data=None, x_model = None, y_model =None, sigma_func = None, sigma_model=None):\n",
"\n", "\n",
" fig,ax = plt.subplots()\n", " fig,ax = plt.subplots()\n",
@@ -137,7 +137,7 @@
"n_data = 15\n", "n_data = 15\n",
"x_data,y_data = generate_data(n_data, sigma_func)\n", "x_data,y_data = generate_data(n_data, sigma_func)\n",
"\n", "\n",
"# Plot the functinon, data and uncertainty\n", "# Plot the function, data and uncertainty\n",
"plot_function(x_func, y_func, x_data, y_data, sigma_func=sigma_func)" "plot_function(x_func, y_func, x_data, y_data, sigma_func=sigma_func)"
], ],
"metadata": { "metadata": {
@@ -216,7 +216,7 @@
"# Closed form solution\n", "# Closed form solution\n",
"beta, omega = fit_model_closed_form(x_data,y_data,n_hidden=14)\n", "beta, omega = fit_model_closed_form(x_data,y_data,n_hidden=14)\n",
"\n", "\n",
"# Get prediction for model across graph grange\n", "# Get prediction for model across graph range\n",
"x_model = np.linspace(0,1,100);\n", "x_model = np.linspace(0,1,100);\n",
"y_model = network(x_model, beta, omega)\n", "y_model = network(x_model, beta, omega)\n",
"\n", "\n",
@@ -297,7 +297,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"# Plot the median of the results\n", "# Plot the mean of the results\n",
"# TODO -- find the mean prediction\n", "# TODO -- find the mean prediction\n",
"# Replace this line\n", "# Replace this line\n",
"y_model_mean = all_y_model[0,:]\n", "y_model_mean = all_y_model[0,:]\n",

View File

@@ -36,7 +36,7 @@
"# import libraries\n", "# import libraries\n",
"import numpy as np\n", "import numpy as np\n",
"import matplotlib.pyplot as plt\n", "import matplotlib.pyplot as plt\n",
"# Define seed so get same results each time\n", "# Define seed to get same results each time\n",
"np.random.seed(1)" "np.random.seed(1)"
] ]
}, },
@@ -85,7 +85,7 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"# Draw the fitted function, together win uncertainty used to generate points\n", "# Draw the fitted function, together with uncertainty used to generate points\n",
"def plot_function(x_func, y_func, x_data=None,y_data=None, x_model = None, y_model =None, sigma_func = None, sigma_model=None):\n", "def plot_function(x_func, y_func, x_data=None,y_data=None, x_model = None, y_model =None, sigma_func = None, sigma_model=None):\n",
"\n", "\n",
" fig,ax = plt.subplots()\n", " fig,ax = plt.subplots()\n",
@@ -220,7 +220,7 @@
" &\\propto&\\text{Norm}_{\\boldsymbol\\phi}\\biggl[\\frac{1}{\\sigma^2}\\left(\\frac{1}{\\sigma^2}\\mathbf{H}\\mathbf{H}^T+\\frac{1}{\\sigma_p^2}\\mathbf{I}\\right)^{-1}\\mathbf{H}\\mathbf{y},\\left(\\frac{1}{\\sigma^2}\\mathbf{H}\\mathbf{H}^T+\\frac{1}{\\sigma_p^2}\\mathbf{I}\\right)^{-1}\\biggr].\n", " &\\propto&\\text{Norm}_{\\boldsymbol\\phi}\\biggl[\\frac{1}{\\sigma^2}\\left(\\frac{1}{\\sigma^2}\\mathbf{H}\\mathbf{H}^T+\\frac{1}{\\sigma_p^2}\\mathbf{I}\\right)^{-1}\\mathbf{H}\\mathbf{y},\\left(\\frac{1}{\\sigma^2}\\mathbf{H}\\mathbf{H}^T+\\frac{1}{\\sigma_p^2}\\mathbf{I}\\right)^{-1}\\biggr].\n",
"\\end{align}\n", "\\end{align}\n",
"\n", "\n",
"In fact, since this already a normal distribution, the constant of proportionality must be one and we can write\n", "In fact, since this is already a normal distribution, the constant of proportionality must be one and we can write\n",
"\n", "\n",
"\\begin{align}\n", "\\begin{align}\n",
" Pr(\\boldsymbol\\phi|\\{\\mathbf{x}_{i},\\mathbf{y}_{i}\\}) &=& \\text{Norm}_{\\boldsymbol\\phi}\\biggl[\\frac{1}{\\sigma^2}\\left(\\frac{1}{\\sigma^2}\\mathbf{H}\\mathbf{H}^T+\\frac{1}{\\sigma_p^2}\\mathbf{I}\\right)^{-1}\\mathbf{H}\\mathbf{y},\\left(\\frac{1}{\\sigma^2}\\mathbf{H}\\mathbf{H}^T+\\frac{1}{\\sigma_p^2}\\mathbf{I}\\right)^{-1}\\biggr].\n", " Pr(\\boldsymbol\\phi|\\{\\mathbf{x}_{i},\\mathbf{y}_{i}\\}) &=& \\text{Norm}_{\\boldsymbol\\phi}\\biggl[\\frac{1}{\\sigma^2}\\left(\\frac{1}{\\sigma^2}\\mathbf{H}\\mathbf{H}^T+\\frac{1}{\\sigma_p^2}\\mathbf{I}\\right)^{-1}\\mathbf{H}\\mathbf{y},\\left(\\frac{1}{\\sigma^2}\\mathbf{H}\\mathbf{H}^T+\\frac{1}{\\sigma_p^2}\\mathbf{I}\\right)^{-1}\\biggr].\n",

View File

@@ -4,7 +4,6 @@
"metadata": { "metadata": {
"colab": { "colab": {
"provenance": [], "provenance": [],
"authorship_tag": "ABX9TyM38ZVBK4/xaHk5Ys5lF6dN",
"include_colab_link": true "include_colab_link": true
}, },
"kernelspec": { "kernelspec": {
@@ -44,8 +43,8 @@
{ {
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"# Run this if you're in a Colab to make a local copy of the MNIST 1D repository\n", "# Run this if you're in a Colab to install MNIST 1D repository\n",
"!git clone https://github.com/greydanus/mnist1d" "!pip install git+https://github.com/greydanus/mnist1d"
], ],
"metadata": { "metadata": {
"id": "syvgxgRr3myY" "id": "syvgxgRr3myY"
@@ -95,7 +94,7 @@
"D_k = 200 # Hidden dimensions\n", "D_k = 200 # Hidden dimensions\n",
"D_o = 10 # Output dimensions\n", "D_o = 10 # Output dimensions\n",
"\n", "\n",
"# Define a model with two hidden layers of size 100\n", "# Define a model with two hidden layers of size 200\n",
"# And ReLU activations between them\n", "# And ReLU activations between them\n",
"model = nn.Sequential(\n", "model = nn.Sequential(\n",
"nn.Linear(D_i, D_k),\n", "nn.Linear(D_i, D_k),\n",
@@ -108,10 +107,7 @@
" # Initialize the parameters with He initialization\n", " # Initialize the parameters with He initialization\n",
" if isinstance(layer_in, nn.Linear):\n", " if isinstance(layer_in, nn.Linear):\n",
" nn.init.kaiming_uniform_(layer_in.weight)\n", " nn.init.kaiming_uniform_(layer_in.weight)\n",
" layer_in.bias.data.fill_(0.0)\n", " layer_in.bias.data.fill_(0.0)\n"
"\n",
"# Call the function you just defined\n",
"model.apply(weights_init)"
], ],
"metadata": { "metadata": {
"id": "JfIFWFIL33eF" "id": "JfIFWFIL33eF"

View File

@@ -4,7 +4,7 @@
"metadata": { "metadata": {
"colab": { "colab": {
"provenance": [], "provenance": [],
"authorship_tag": "ABX9TyNJodaaCLMRWL9vTl8B/iLI", "authorship_tag": "ABX9TyNb46PJB/CC1pcHGfjpUUZg",
"include_colab_link": true "include_colab_link": true
}, },
"kernelspec": { "kernelspec": {
@@ -45,8 +45,8 @@
{ {
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"# Run this if you're in a Colab to make a local copy of the MNIST 1D repository\n", "# Run this if you're in a Colab to install MNIST 1D repository\n",
"!git clone https://github.com/greydanus/mnist1d" "!pip install git+https://github.com/greydanus/mnist1d"
], ],
"metadata": { "metadata": {
"id": "D5yLObtZCi9J" "id": "D5yLObtZCi9J"

View File

@@ -31,7 +31,7 @@
"source": [ "source": [
"# **Notebook 10.4: Downsampling and Upsampling**\n", "# **Notebook 10.4: Downsampling and Upsampling**\n",
"\n", "\n",
"This notebook investigates the down sampling and downsampling methods discussed in section 10.4 of the book.\n", "This notebook investigates the upsampling and downsampling methods discussed in section 10.4 of the book.\n",
"\n", "\n",
"Work through the cells below, running each cell in turn. In various places you will see the words \"TODO\". Follow the instructions at these places and make predictions about what is going to happen or write code to complete the functions.\n", "Work through the cells below, running each cell in turn. In various places you will see the words \"TODO\". Follow the instructions at these places and make predictions about what is going to happen or write code to complete the functions.\n",
"\n", "\n",
@@ -301,7 +301,7 @@
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"# Define 2 by 2 original patch\n", "# Define 2 by 2 original patch\n",
"orig_2_2 = np.array([[2, 4], [4,8]])\n", "orig_2_2 = np.array([[6, 8], [8,4]])\n",
"print(orig_2_2)" "print(orig_2_2)"
], ],
"metadata": { "metadata": {

View File

@@ -4,7 +4,7 @@
"metadata": { "metadata": {
"colab": { "colab": {
"provenance": [], "provenance": [],
"authorship_tag": "ABX9TyNAcc98STMeyQgh9SbVHWG+", "authorship_tag": "ABX9TyORZF8xy4X1yf4oRhRq8Rtm",
"include_colab_link": true "include_colab_link": true
}, },
"kernelspec": { "kernelspec": {
@@ -65,10 +65,19 @@
"source": [ "source": [
"# Run this once to load the train and test data straight into a dataloader class\n", "# Run this once to load the train and test data straight into a dataloader class\n",
"# that will provide the batches\n", "# that will provide the batches\n",
"\n",
"# (It may complain that some files are missing because the files seem to have been\n",
"# reorganized on the underlying website, but it still seems to work). If everything is working\n",
"# properly, then the whole notebook should run to the end without further problems\n",
"# even before you make changes.\n",
"batch_size_train = 64\n", "batch_size_train = 64\n",
"batch_size_test = 1000\n", "batch_size_test = 1000\n",
"\n",
"# TODO Change this directory to point towards an existing directory\n",
"myDir = '/files/'\n",
"\n",
"train_loader = torch.utils.data.DataLoader(\n", "train_loader = torch.utils.data.DataLoader(\n",
" torchvision.datasets.MNIST('/files/', train=True, download=True,\n", " torchvision.datasets.MNIST(myDir, train=True, download=True,\n",
" transform=torchvision.transforms.Compose([\n", " transform=torchvision.transforms.Compose([\n",
" torchvision.transforms.ToTensor(),\n", " torchvision.transforms.ToTensor(),\n",
" torchvision.transforms.Normalize(\n", " torchvision.transforms.Normalize(\n",
@@ -77,7 +86,7 @@
" batch_size=batch_size_train, shuffle=True)\n", " batch_size=batch_size_train, shuffle=True)\n",
"\n", "\n",
"test_loader = torch.utils.data.DataLoader(\n", "test_loader = torch.utils.data.DataLoader(\n",
" torchvision.datasets.MNIST('/files/', train=False, download=True,\n", " torchvision.datasets.MNIST(myDir, train=False, download=True,\n",
" transform=torchvision.transforms.Compose([\n", " transform=torchvision.transforms.Compose([\n",
" torchvision.transforms.ToTensor(),\n", " torchvision.transforms.ToTensor(),\n",
" torchvision.transforms.Normalize(\n", " torchvision.transforms.Normalize(\n",

View File

@@ -4,7 +4,7 @@
"metadata": { "metadata": {
"colab": { "colab": {
"provenance": [], "provenance": [],
"authorship_tag": "ABX9TyMXS3SPB4cS/4qxix0lH/Hq", "authorship_tag": "ABX9TyNIY8tswL9e48d5D53aSmHO",
"include_colab_link": true "include_colab_link": true
}, },
"kernelspec": { "kernelspec": {
@@ -45,8 +45,8 @@
{ {
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"# Run this if you're in a Colab to make a local copy of the MNIST 1D repository\n", "# Run this if you're in a Colab to install MNIST 1D repository\n",
"!git clone https://github.com/greydanus/mnist1d" "!pip install git+https://github.com/greydanus/mnist1d"
], ],
"metadata": { "metadata": {
"id": "D5yLObtZCi9J" "id": "D5yLObtZCi9J"

View File

@@ -4,7 +4,7 @@
"metadata": { "metadata": {
"colab": { "colab": {
"provenance": [], "provenance": [],
"authorship_tag": "ABX9TyPVeAd3eDpEOCFh8CVyr1zz", "authorship_tag": "ABX9TyPx2mM2zTHmDJeKeiE1RymT",
"include_colab_link": true "include_colab_link": true
}, },
"kernelspec": { "kernelspec": {
@@ -45,8 +45,8 @@
{ {
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"# Run this if you're in a Colab to make a local copy of the MNIST 1D repository\n", "# Run this if you're in a Colab to install MNIST 1D repository\n",
"!git clone https://github.com/greydanus/mnist1d" "!pip install git+https://github.com/greydanus/mnist1d"
], ],
"metadata": { "metadata": {
"id": "D5yLObtZCi9J" "id": "D5yLObtZCi9J"

View File

@@ -28,7 +28,7 @@
{ {
"cell_type": "markdown", "cell_type": "markdown",
"source": [ "source": [
"# **Notebook 12.1: Multhead Self-Attention**\n", "# **Notebook 12.2: Multihead Self-Attention**\n",
"\n", "\n",
"This notebook builds a multihead self-attention mechanism as in figure 12.6\n", "This notebook builds a multihead self-attention mechanism as in figure 12.6\n",
"\n", "\n",

View File

@@ -4,7 +4,6 @@
"metadata": { "metadata": {
"colab": { "colab": {
"provenance": [], "provenance": [],
"authorship_tag": "ABX9TyOMSGUFWT+YN0fwYHpMmHJM",
"include_colab_link": true "include_colab_link": true
}, },
"kernelspec": { "kernelspec": {
@@ -99,7 +98,7 @@
"\n", "\n",
"# TODO -- Define node matrix\n", "# TODO -- Define node matrix\n",
"# There will be 9 nodes and 118 possible chemical elements\n", "# There will be 9 nodes and 118 possible chemical elements\n",
"# so we'll define a 9x118 matrix. Each column represents one\n", "# so we'll define a 118x9 matrix. Each column represents one\n",
"# node and is a one-hot vector (i.e. all zeros, except a single one at the\n", "# node and is a one-hot vector (i.e. all zeros, except a single one at the\n",
"# chemical number of the element).\n", "# chemical number of the element).\n",
"# Chemical numbers: Hydrogen-->1, Carbon-->6, Oxygen-->8\n", "# Chemical numbers: Hydrogen-->1, Carbon-->6, Oxygen-->8\n",

View File

@@ -109,7 +109,7 @@
"# Choose random values for the parameters\n", "# Choose random values for the parameters\n",
"omega = np.random.normal(size=(D,D))\n", "omega = np.random.normal(size=(D,D))\n",
"beta = np.random.normal(size=(D,1))\n", "beta = np.random.normal(size=(D,1))\n",
"phi = np.random.normal(size=(1,2*D))" "phi = np.random.normal(size=(2*D,1))"
], ],
"metadata": { "metadata": {
"id": "79TSK7oLMobe" "id": "79TSK7oLMobe"

View File

@@ -4,7 +4,6 @@
"metadata": { "metadata": {
"colab": { "colab": {
"provenance": [], "provenance": [],
"authorship_tag": "ABX9TyM0StKV3FIZ3MZqfflqC0Rv",
"include_colab_link": true "include_colab_link": true
}, },
"kernelspec": { "kernelspec": {
@@ -339,7 +338,7 @@
" print(\"Initial generator loss = \", compute_generator_loss(z, theta, phi0, phi1))\n", " print(\"Initial generator loss = \", compute_generator_loss(z, theta, phi0, phi1))\n",
" for iter in range(n_iter):\n", " for iter in range(n_iter):\n",
" # Get gradient\n", " # Get gradient\n",
" dl_dtheta = compute_generator_gradient(x_real, x_syn, phi0, phi1)\n", " dl_dtheta = compute_generator_gradient(z, theta, phi0, phi1)\n",
" # Take a gradient step (uphill, since we are trying to make synthesized data less well classified by discriminator)\n", " # Take a gradient step (uphill, since we are trying to make synthesized data less well classified by discriminator)\n",
" theta = theta + alpha * dl_dtheta ;\n", " theta = theta + alpha * dl_dtheta ;\n",
"\n", "\n",

View File

@@ -86,6 +86,7 @@
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"# TODO Define the distance matrix from figure 15.8d\n", "# TODO Define the distance matrix from figure 15.8d\n",
"# The index should be normalized before being used in the distance calculation.\n",
"# Replace this line\n", "# Replace this line\n",
"dist_mat = np.zeros((10,10))\n", "dist_mat = np.zeros((10,10))\n",
"\n", "\n",
@@ -218,7 +219,8 @@
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"was = np.sum(TP * dist_mat)\n", "was = np.sum(TP * dist_mat)\n",
"print(\"Wasserstein distance = \", was)" "print(\"Your Wasserstein distance = \", was)\n",
"print(\"Correct answer = 0.15148578811369506\")"
], ],
"metadata": { "metadata": {
"id": "yiQ_8j-Raq3c" "id": "yiQ_8j-Raq3c"

View File

@@ -55,7 +55,7 @@
"Pr(z) = \\text{Norm}_{z}[0,1]\n", "Pr(z) = \\text{Norm}_{z}[0,1]\n",
"\\end{equation}\n", "\\end{equation}\n",
"\n", "\n",
"As in figure 17.2, we'll assume that the output is two dimensional, we we need to define a function that maps from the 1D latent variable to two dimensions. Usually, we would use a neural network, but in this case, we'll just define an arbitrary relationship.\n", "As in figure 17.2, we'll assume that the output is two dimensional, we need to define a function that maps from the 1D latent variable to two dimensions. Usually, we would use a neural network, but in this case, we'll just define an arbitrary relationship.\n",
"\n", "\n",
"\\begin{align}\n", "\\begin{align}\n",
"x_{1} &=& 0.5\\cdot\\exp\\Bigl[\\sin\\bigl[2+ 3.675 z \\bigr]\\Bigr]\\\\\n", "x_{1} &=& 0.5\\cdot\\exp\\Bigl[\\sin\\bigl[2+ 3.675 z \\bigr]\\Bigr]\\\\\n",

View File

@@ -1,18 +1,16 @@
{ {
"cells": [ "cells": [
{ {
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"metadata": { "metadata": {
"colab_type": "text", "id": "view-in-github",
"id": "view-in-github" "colab_type": "text"
}, },
"source": [ "source": [
"<a href=\"https://colab.research.google.com/github/udlbook/udlbook/blob/main/Notebooks/Chap17/17_3_Importance_Sampling.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>" "<a href=\"https://colab.research.google.com/github/udlbook/udlbook/blob/main/Notebooks/Chap17/17_3_Importance_Sampling.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
] ]
}, },
{ {
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"metadata": { "metadata": {
"id": "t9vk9Elugvmi" "id": "t9vk9Elugvmi"
@@ -40,7 +38,6 @@
] ]
}, },
{ {
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"metadata": { "metadata": {
"id": "f7a6xqKjkmvT" "id": "f7a6xqKjkmvT"
@@ -61,7 +58,7 @@
"by drawing $I$ samples $y_i$ and using the formula:\n", "by drawing $I$ samples $y_i$ and using the formula:\n",
"\n", "\n",
"\\begin{equation}\n", "\\begin{equation}\n",
"\\mathbb{E}_{y}\\Bigl[\\exp\\bigl[- (y-1)^4\\bigr]\\Bigr] \\approx \\frac{1}{I} \\sum_{i=1}^I \\exp\\bigl[-(y-1)^4 \\bigr]\n", "\\mathbb{E}_{y}\\Bigl[\\exp\\bigl[- (y-1)^4\\bigr]\\Bigr] \\approx \\frac{1}{I} \\sum_{i=1}^I \\exp\\bigl[-(y_i-1)^4 \\bigr]\n",
"\\end{equation}" "\\end{equation}"
] ]
}, },
@@ -126,7 +123,6 @@
] ]
}, },
{ {
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"metadata": { "metadata": {
"id": "Jr4UPcqmnXCS" "id": "Jr4UPcqmnXCS"
@@ -166,8 +162,8 @@
"mean_all = np.zeros_like(n_sample_all)\n", "mean_all = np.zeros_like(n_sample_all)\n",
"variance_all = np.zeros_like(n_sample_all)\n", "variance_all = np.zeros_like(n_sample_all)\n",
"for i in range(len(n_sample_all)):\n", "for i in range(len(n_sample_all)):\n",
" print(\"Computing mean and variance for expectation with %d samples\"%(n_sample_all[i]))\n", " mean_all[i],variance_all[i] = compute_mean_variance(n_sample_all[i])\n",
" mean_all[i],variance_all[i] = compute_mean_variance(n_sample_all[i])" " print(\"No samples: \", n_sample_all[i], \", Mean: \", mean_all[i], \", Variance: \", variance_all[i])"
] ]
}, },
{ {
@@ -189,7 +185,6 @@
] ]
}, },
{ {
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"metadata": { "metadata": {
"id": "XTUpxFlSuOl7" "id": "XTUpxFlSuOl7"
@@ -199,7 +194,6 @@
] ]
}, },
{ {
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"metadata": { "metadata": {
"id": "6hxsl3Pxo1TT" "id": "6hxsl3Pxo1TT"
@@ -234,7 +228,6 @@
] ]
}, },
{ {
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"metadata": { "metadata": {
"id": "G9Xxo0OJsIqD" "id": "G9Xxo0OJsIqD"
@@ -283,7 +276,6 @@
] ]
}, },
{ {
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"metadata": { "metadata": {
"id": "2sVDqP0BvxqM" "id": "2sVDqP0BvxqM"
@@ -313,8 +305,8 @@
"mean_all2 = np.zeros_like(n_sample_all)\n", "mean_all2 = np.zeros_like(n_sample_all)\n",
"variance_all2 = np.zeros_like(n_sample_all)\n", "variance_all2 = np.zeros_like(n_sample_all)\n",
"for i in range(len(n_sample_all)):\n", "for i in range(len(n_sample_all)):\n",
" print(\"Computing variance for expectation with %d samples\"%(n_sample_all[i]))\n", " mean_all2[i], variance_all2[i] = compute_mean_variance2(n_sample_all[i])\n",
" mean_all2[i], variance_all2[i] = compute_mean_variance2(n_sample_all[i])" " print(\"No samples: \", n_sample_all[i], \", Mean: \", mean_all2[i], \", Variance: \", variance_all2[i])"
] ]
}, },
{ {
@@ -348,7 +340,6 @@
] ]
}, },
{ {
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"metadata": { "metadata": {
"id": "EtBP6NeLwZqz" "id": "EtBP6NeLwZqz"
@@ -360,7 +351,6 @@
] ]
}, },
{ {
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"metadata": { "metadata": {
"id": "_wuF-NoQu1--" "id": "_wuF-NoQu1--"
@@ -432,8 +422,8 @@
"mean_all2b = np.zeros_like(n_sample_all)\n", "mean_all2b = np.zeros_like(n_sample_all)\n",
"variance_all2b = np.zeros_like(n_sample_all)\n", "variance_all2b = np.zeros_like(n_sample_all)\n",
"for i in range(len(n_sample_all)):\n", "for i in range(len(n_sample_all)):\n",
" print(\"Computing variance for expectation with %d samples\"%(n_sample_all[i]))\n", " mean_all2b[i], variance_all2b[i] = compute_mean_variance2b(n_sample_all[i])\n",
" mean_all2b[i], variance_all2b[i] = compute_mean_variance2b(n_sample_all[i])" " print(\"No samples: \", n_sample_all[i], \", Mean: \", mean_all2b[i], \", Variance: \", variance_all2b[i])"
] ]
}, },
{ {
@@ -478,7 +468,6 @@
] ]
}, },
{ {
"attachments": {},
"cell_type": "markdown", "cell_type": "markdown",
"metadata": { "metadata": {
"id": "y8rgge9MNiOc" "id": "y8rgge9MNiOc"
@@ -490,9 +479,8 @@
], ],
"metadata": { "metadata": {
"colab": { "colab": {
"authorship_tag": "ABX9TyNecz9/CDOggPSmy1LjT/Dv", "provenance": [],
"include_colab_link": true, "include_colab_link": true
"provenance": []
}, },
"kernelspec": { "kernelspec": {
"display_name": "Python 3", "display_name": "Python 3",

View File

@@ -4,7 +4,6 @@
"metadata": { "metadata": {
"colab": { "colab": {
"provenance": [], "provenance": [],
"authorship_tag": "ABX9TyOlD6kmCxX3SKKuh3oJikKA",
"include_colab_link": true "include_colab_link": true
}, },
"kernelspec": { "kernelspec": {
@@ -393,7 +392,7 @@
{ {
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"# Update the state values for the current policy, by making the values at at adjacent\n", "# Update the state values for the current policy, by making the values at adjacent\n",
"# states compatible with the Bellman equation (equation 19.11)\n", "# states compatible with the Bellman equation (equation 19.11)\n",
"def policy_evaluation(policy, state_values, rewards, transition_probabilities_given_action, gamma):\n", "def policy_evaluation(policy, state_values, rewards, transition_probabilities_given_action, gamma):\n",
"\n", "\n",
@@ -406,6 +405,10 @@
" state_values_new[state] = 3.0\n", " state_values_new[state] = 3.0\n",
" break\n", " break\n",
"\n", "\n",
" # TODO -- Write this function (from equation 19.11, but bear in mind policy is deterministic here)\n",
" # Replace this line\n",
" state_values_new[state] = 0\n",
"\n",
" return state_values_new\n", " return state_values_new\n",
"\n", "\n",
"# Greedily choose the action that maximizes the value for each state.\n", "# Greedily choose the action that maximizes the value for each state.\n",

View File

@@ -4,7 +4,7 @@
"metadata": { "metadata": {
"colab": { "colab": {
"provenance": [], "provenance": [],
"authorship_tag": "ABX9TyPkSYbEjOcEmLt8tU6HxNuR", "authorship_tag": "ABX9TyNgBRvfIlngVobKuLE6leM+",
"include_colab_link": true "include_colab_link": true
}, },
"kernelspec": { "kernelspec": {
@@ -45,8 +45,8 @@
{ {
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"# Run this if you're in a Colab to make a local copy of the MNIST 1D repository\n", "# Run this if you're in a Colab to install MNIST 1D repository\n",
"!git clone https://github.com/greydanus/mnist1d" "!pip install git+https://github.com/greydanus/mnist1d"
], ],
"metadata": { "metadata": {
"id": "D5yLObtZCi9J" "id": "D5yLObtZCi9J"

View File

@@ -4,7 +4,7 @@
"metadata": { "metadata": {
"colab": { "colab": {
"provenance": [], "provenance": [],
"authorship_tag": "ABX9TyOo4vm4MXcIvAzVlMCaLikH", "authorship_tag": "ABX9TyO6xuszaG4nNAcWy/3juLkn",
"include_colab_link": true "include_colab_link": true
}, },
"kernelspec": { "kernelspec": {
@@ -44,8 +44,8 @@
{ {
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"# Run this if you're in a Colab to make a local copy of the MNIST 1D repository\n", "# Run this if you're in a Colab to install MNIST 1D repository\n",
"!git clone https://github.com/greydanus/mnist1d" "!pip install git+https://github.com/greydanus/mnist1d"
], ],
"metadata": { "metadata": {
"id": "D5yLObtZCi9J" "id": "D5yLObtZCi9J"

View File

@@ -5,7 +5,7 @@
"colab": { "colab": {
"provenance": [], "provenance": [],
"gpuType": "T4", "gpuType": "T4",
"authorship_tag": "ABX9TyMjPBfDONmjqTSyEQDP2gjY", "authorship_tag": "ABX9TyOG/5A+P053/x1IfFg52z4V",
"include_colab_link": true "include_colab_link": true
}, },
"kernelspec": { "kernelspec": {
@@ -47,8 +47,8 @@
{ {
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"# Run this if you're in a Colab to make a local copy of the MNIST 1D repository\n", "# Run this if you're in a Colab to install MNIST 1D repository\n",
"!git clone https://github.com/greydanus/mnist1d" "!pip install git+https://github.com/greydanus/mnist1d"
], ],
"metadata": { "metadata": {
"id": "D5yLObtZCi9J" "id": "D5yLObtZCi9J"

View File

@@ -43,7 +43,8 @@
"id": "Sg2i1QmhKW5d" "id": "Sg2i1QmhKW5d"
}, },
"source": [ "source": [
"# Run this if you're in a Colab\n", "# Run this if you're in a Colab to install MNIST 1D repository\n",
"!pip install git+https://github.com/greydanus/mnist1d\n",
"!git clone https://github.com/greydanus/mnist1d" "!git clone https://github.com/greydanus/mnist1d"
], ],
"execution_count": null, "execution_count": null,
@@ -95,6 +96,12 @@
"id": "I-vm_gh5xTJs" "id": "I-vm_gh5xTJs"
}, },
"source": [ "source": [
"from mnist1d.data import get_dataset, get_dataset_args\n",
"from mnist1d.utils import set_seed, to_pickle, from_pickle\n",
"\n",
"import sys ; sys.path.append('./mnist1d/notebooks')\n",
"from train import get_model_args, train_model\n",
"\n",
"args = mnist1d.get_dataset_args()\n", "args = mnist1d.get_dataset_args()\n",
"data = mnist1d.get_dataset(args=args) # by default, this will download a pre-made dataset from the GitHub repo\n", "data = mnist1d.get_dataset(args=args) # by default, this will download a pre-made dataset from the GitHub repo\n",
"\n", "\n",
@@ -210,7 +217,7 @@
" # we would return [1,1,0,0,1]\n", " # we would return [1,1,0,0,1]\n",
" # Remember that these are torch tensors and not numpy arrays\n", " # Remember that these are torch tensors and not numpy arrays\n",
" # Replace this function:\n", " # Replace this function:\n",
" mask = torch.ones_like(scores)\n", " mask = torch.ones_like(absolute_weights)\n",
"\n", "\n",
"\n", "\n",
" return mask" " return mask"
@@ -237,7 +244,6 @@
"def find_lottery_ticket(model, dataset, args, sparsity_schedule, criteria_fn=None, **kwargs):\n", "def find_lottery_ticket(model, dataset, args, sparsity_schedule, criteria_fn=None, **kwargs):\n",
"\n", "\n",
" criteria_fn = lambda init_params, final_params: final_params.abs()\n", " criteria_fn = lambda init_params, final_params: final_params.abs()\n",
"\n",
" init_params = model.get_layer_vecs()\n", " init_params = model.get_layer_vecs()\n",
" stats = {'train_losses':[], 'test_losses':[], 'train_accs':[], 'test_accs':[]}\n", " stats = {'train_losses':[], 'test_losses':[], 'train_accs':[], 'test_accs':[]}\n",
" models = []\n", " models = []\n",
@@ -253,7 +259,7 @@
" model.set_layer_masks(masks)\n", " model.set_layer_masks(masks)\n",
"\n", "\n",
" # training process\n", " # training process\n",
" results = mnist1d.train_model(dataset, model, args)\n", " results = train_model(dataset, model, args)\n",
" model = results['checkpoints'][-1]\n", " model = results['checkpoints'][-1]\n",
"\n", "\n",
" # store stats\n", " # store stats\n",
@@ -291,7 +297,8 @@
}, },
"source": [ "source": [
"# train settings\n", "# train settings\n",
"model_args = mnist1d.get_model_args()\n", "from train import get_model_args, train_model\n",
"model_args = get_model_args()\n",
"model_args.total_steps = 1501\n", "model_args.total_steps = 1501\n",
"model_args.hidden_size = 500\n", "model_args.hidden_size = 500\n",
"model_args.print_every = 5000 # print never\n", "model_args.print_every = 5000 # print never\n",

View File

@@ -137,7 +137,7 @@
"id": "CfZ-srQtmff2" "id": "CfZ-srQtmff2"
}, },
"source": [ "source": [
"Why might the distributions for blue and yellow populations be different? It could be that the behaviour of the populations is identical, but the credit rating algorithm is biased; it may favor one population over another or simply be more noisy for one group. Alternatively, it could be that that the populations genuinely behave differently. In practice, the differences in blue and yellow distributions are probably attributable to a combination of these factors.\n", "Why might the distributions for blue and yellow populations be different? It could be that the behaviour of the populations is identical, but the credit rating algorithm is biased; it may favor one population over another or simply be more noisy for one group. Alternatively, it could be that the populations genuinely behave differently. In practice, the differences in blue and yellow distributions are probably attributable to a combination of these factors.\n",
"\n", "\n",
"Lets assume that we cant retrain the credit score prediction algorithm; our job is to adjudicate whether each individual is refused the loan ($\\hat{y}=0$)\n", "Lets assume that we cant retrain the credit score prediction algorithm; our job is to adjudicate whether each individual is refused the loan ($\\hat{y}=0$)\n",
" or granted it ($\\hat{y}=1$). Since we only have the credit score\n", " or granted it ($\\hat{y}=1$). Since we only have the credit score\n",
@@ -382,7 +382,7 @@
"source": [ "source": [
"# Equal opportunity:\n", "# Equal opportunity:\n",
"\n", "\n",
"The thresholds are chosen so that so that the true positive rate is is the same for both population. Of the people who pay back the loan, the same proportion are offered credit in each group. In terms of the two ROC curves, it means choosing thresholds so that the vertical position on each curve is the same without regard for the horizontal position." "The thresholds are chosen so that so that the true positive rate is the same for both population. Of the people who pay back the loan, the same proportion are offered credit in each group. In terms of the two ROC curves, it means choosing thresholds so that the vertical position on each curve is the same without regard for the horizontal position."
] ]
}, },
{ {

7
Notebooks/LICENSE (MIT) Normal file
View File

@@ -0,0 +1,7 @@
Copyright 2023 Simon Prince
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

1061
Trees/SAT_Crossword.ipynb Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

248
Trees/SAT_Exhaustive.ipynb Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

270
Trees/SAT_Sudoku.ipynb Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

251
Trees/SAT_Tseitin.ipynb Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

264
Trees/SAT_Z3.ipynb Normal file

File diff suppressed because one or more lines are too long

335
Trees/SAT_Z3_Answers.ipynb Normal file

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

Binary file not shown.

2229
UDL_Equations.tex Normal file

File diff suppressed because it is too large Load Diff

Binary file not shown.

20
index.html Normal file
View File

@@ -0,0 +1,20 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="icon" type="image/x-icon" href="/favicon.ico" />
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Encode+Sans+Expanded:wght@400;700&display=swap"
rel="stylesheet"
/>
<title>Understanding Deep Learning</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/index.jsx"></script>
</body>
</html>

View File

@@ -1,406 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>udlbook</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div id="head">
<div>
<h1 style="margin: 0; font-size: 36px">Understanding Deep Learning</h1>
by Simon J.D. Prince
<br>Published by MIT Press Dec 5th 2023.<br>
<ul>
<li>
<p style="font-size: larger; margin-bottom: 0">Download full PDF <a
href="https://github.com/udlbook/udlbook/releases/download/v2.03/UnderstandingDeepLearning_02_26_24_C.pdf">here</a>
</p>2024-03-26. CC-BY-NC-ND license<br>
<img src="https://img.shields.io/github/downloads/udlbook/udlbook/total" alt="download stats shield">
</li>
<li> Order your copy from <a href="https://mitpress.mit.edu/9780262048644/understanding-deep-learning/">here </a></li>
<li> Known errata can be found here: <a
href="https://github.com/udlbook/udlbook/raw/main/UDL_Errata.pdf">PDF</a></li>
<li> Report new errata via <a href="https://github.com/udlbook/udlbook/issues">github</a>
or contact me directly at udlbookmail@gmail.com
<li> Follow me on <a href="https://twitter.com/SimonPrinceAI">Twitter</a> or <a
href="https://www.linkedin.com/in/simon-prince-615bb9165/">LinkedIn</a> for updates.
</ul>
<h2>Table of contents</h2>
<ul>
<li> Chapter 1 - Introduction
<li> Chapter 2 - Supervised learning
<li> Chapter 3 - Shallow neural networks
<li> Chapter 4 - Deep neural networks
<li> Chapter 5 - Loss functions
<li> Chapter 6 - Training models
<li> Chapter 7 - Gradients and initialization
<li> Chapter 8 - Measuring performance
<li> Chapter 9 - Regularization
<li> Chapter 10 - Convolutional networks
<li> Chapter 11 - Residual networks
<li> Chapter 12 - Transformers
<li> Chapter 13 - Graph neural networks
<li> Chapter 14 - Unsupervised learning
<li> Chapter 15 - Generative adversarial networks
<li> Chapter 16 - Normalizing flows
<li> Chapter 17 - Variational autoencoders
<li> Chapter 18 - Diffusion models
<li> Chapter 19 - Deep reinforcement learning
<li> Chapter 20 - Why does deep learning work?
<li> Chapter 21 - Deep learning and ethics
</ul>
</div>
<div id="cover">
<img src="https://raw.githubusercontent.com/udlbook/udlbook/main/UDLCoverSmall.jpg"
alt="front cover">
</div>
</div>
<div id="body">
<h2>Resources for instructors </h2>
<p>Instructor answer booklet available with proof of credentials via <a
href="https://mitpress.mit.edu/9780262048644/understanding-deep-learning"> MIT Press</a>.</p>
<p>Request an exam/desk copy via <a href="https://mitpress.ublish.com/request?cri=15055">MIT Press</a>.</p>
<p>Figures in PDF (vector) / SVG (vector) / Powerpoint (images):
<ul>
<li> Chapter 1 - Introduction: <a href="https://github.com/udlbook/udlbook/raw/main/PDFFigures/UDLChap1PDF.zip">PDF
Figures</a> / <a href="https://drive.google.com/uc?export=download&id=1udnl5pUOAc8DcAQ7HQwyzP9pwL95ynnv">
SVG
Figures</a> / <a
href="https://docs.google.com/presentation/d/1IjTqIUvWCJc71b5vEJYte-Dwujcp7rvG/edit?usp=drive_link&ouid=110441678248547154185&rtpof=true&sd=true">PowerPoint
Figures</a>
<li> Chapter 2 - Supervised learning: <a
href="https://github.com/udlbook/udlbook/raw/main/PDFFigures/UDLChap2PDF.zip">PDF Figures</a> / <a
href="https://drive.google.com/uc?export=download&id=1VSxcU5y1qNFlmd3Lb3uOWyzILuOj1Dla"> SVG Figures</a>
/
<a href="https://docs.google.com/presentation/d/1Br7R01ROtRWPlNhC_KOommeHAWMBpWtz/edit?usp=drive_link&ouid=110441678248547154185&rtpof=true&sd=true">PowerPoint
Figures</a>
<li> Chapter 3 - Shallow neural networks: <a
href="https://github.com/udlbook/udlbook/raw/main/PDFFigures/UDLChap3PDF.zip">PDF Figures</a> / <a
href="https://drive.google.com/uc?export=download&id=19kZFWlXhzN82Zx02ByMmSZOO4T41fmqI"> SVG Figures</a>
/
<a href="https://docs.google.com/presentation/d/1e9M3jB5I9qZ4dCBY90Q3Hwft_i068QVQ/edit?usp=drive_link&ouid=110441678248547154185&rtpof=true&sd=true">PowerPoint
Figures</a>
<li> Chapter 4 - Deep neural networks: <a
href="https://github.com/udlbook/udlbook/raw/main/PDFFigures/UDLChap4PDF.zip">PDF Figures</a> / <a
href="https://drive.google.com/uc?export=download&id=1ojr0ebsOhzvS04ItAflX2cVmYqHQHZUa"> SVG Figures</a>
/
<a href="https://docs.google.com/presentation/d/1LTSsmY4mMrJbqXVvoTOCkQwHrRKoYnJj/edit?usp=drive_link&ouid=110441678248547154185&rtpof=true&sd=true">PowerPoint
Figures</a>
<li> Chapter 5 - Loss functions: <a
href="https://github.com/udlbook/udlbook/raw/main/PDFFigures/UDLChap5PDF.zip">PDF
Figures</a> / <a href="https://drive.google.com/uc?export=download&id=17MJO7fiMpFZVqKeqXTbQ36AMpmR4GizZ">
SVG
Figures</a> / <a
href="https://docs.google.com/presentation/d/1gcpC_3z9oRp87eMkoco-kdLD-MM54Puk/edit?usp=drive_link&ouid=110441678248547154185&rtpof=true&sd=true">PowerPoint
Figures</a>
<li> Chapter 6 - Training models: <a
href="https://github.com/udlbook/udlbook/raw/main/PDFFigures/UDLChap6PDF.zip">PDF
Figures</a> / <a href="https://drive.google.com/uc?export=download&id=1VPdhFRnCr9_idTrX0UdHKGAw2shUuwhK">
SVG
Figures</a> / <a
href="https://docs.google.com/presentation/d/1AKoeggAFBl9yLC7X5tushAGzCCxmB7EY/edit?usp=drive_link&ouid=110441678248547154185&rtpof=true&sd=true">PowerPoint
Figures</a>
<li> Chapter 7 - Gradients and initialization: <a
href="https://github.com/udlbook/udlbook/raw/main/PDFFigures/UDLChap7PDF.zip">PDF Figures</a> / <a
href="https://drive.google.com/uc?export=download&id=1TTl4gvrTvNbegnml4CoGoKOOd6O8-PGs"> SVG Figures</a>
/
<a href="https://docs.google.com/presentation/d/11zhB6PI-Dp6Ogmr4IcI6fbvbqNqLyYcz/edit?usp=drive_link&ouid=110441678248547154185&rtpof=true&sd=true">PowerPoint
Figures</a>
<li> Chapter 8 - Measuring performance: <a
href="https://github.com/udlbook/udlbook/raw/main/PDFFigures/UDLChap8PDF.zip">PDF Figures</a> / <a
href="https://drive.google.com/uc?export=download&id=19eQOnygd_l0DzgtJxXuYnWa4z7QKJrJx"> SVG Figures</a>
/
<a href="https://docs.google.com/presentation/d/1SHRmJscDLUuQrG7tmysnScb3ZUAqVMZo/edit?usp=drive_link&ouid=110441678248547154185&rtpof=true&sd=true">PowerPoint
Figures</a>
<li> Chapter 9 - Regularization: <a
href="https://github.com/udlbook/udlbook/raw/main/PDFFigures/UDLChap9PDF.zip">PDF
Figures</a> / <a href="https://drive.google.com/uc?export=download&id=1LprgnUGL7xAM9-jlGZC9LhMPeefjY0r0">
SVG
Figures</a> / <a
href="https://docs.google.com/presentation/d/1VwIfvjpdfTny6sEfu4ZETwCnw6m8Eg-5/edit?usp=drive_link&ouid=110441678248547154185&rtpof=true&sd=true">PowerPoint
Figures</a>
<li> Chapter 10 - Convolutional networks: <a
href="https://github.com/udlbook/udlbook/raw/main/PDFFigures/UDLChap10PDF.zip">PDF Figures</a> / <a
href="https://drive.google.com/uc?export=download&id=1-Wb3VzaSvVeRzoUzJbI2JjZE0uwqupM9"> SVG Figures</a>
/
<a href="https://docs.google.com/presentation/d/1MtfKBC4Y9hWwGqeP6DVwUNbi1j5ncQCg/edit?usp=drive_link&ouid=110441678248547154185&rtpof=true&sd=true">PowerPoint
Figures</a>
<li> Chapter 11 - Residual networks: <a
href="https://github.com/udlbook/udlbook/raw/main/PDFFigures/UDLChap11PDF.zip">PDF Figures</a> / <a
href="https://drive.google.com/uc?export=download&id=1Mr58jzEVseUAfNYbGWCQyDtEDwvfHRi1"> SVG Figures</a>
/
<a href="https://docs.google.com/presentation/d/1saY8Faz0KTKAAifUrbkQdLA2qkyEjOPI/edit?usp=drive_link&ouid=110441678248547154185&rtpof=true&sd=true">PowerPoint
Figures</a>
<li> Chapter 12 - Transformers: <a
href="https://github.com/udlbook/udlbook/raw/main/PDFFigures/UDLChap12PDF.zip">PDF
Figures</a> / <a href="https://drive.google.com/uc?export=download&id=1txzOVNf8-jH4UfJ6SLnrtOfPd1Q3ebzd">
SVG
Figures</a> / <a
href="https://docs.google.com/presentation/d/1GVNvYWa0WJA6oKg89qZre-UZEhABfm0l/edit?usp=drive_link&ouid=110441678248547154185&rtpof=true&sd=true">PowerPoint
Figures</a>
<li> Chapter 13 - Graph neural networks: <a
href="https://github.com/udlbook/udlbook/raw/main/PDFFigures/UDLChap13PDF.zip">PDF Figures</a> / <a
href="https://drive.google.com/uc?export=download&id=1lQIV6nRp6LVfaMgpGFhuwEXG-lTEaAwe"> SVG Figures</a>
/
<a href="https://docs.google.com/presentation/d/1YwF3U82c1mQ74c1WqHVTzLZ0j7GgKaWP/edit?usp=drive_link&ouid=110441678248547154185&rtpof=true&sd=true">PowerPoint
Figures</a>
<li> Chapter 14 - Unsupervised learning: <a
href="https://github.com/udlbook/udlbook/raw/main/PDFFigures/UDLChap14PDF.zip">PDF Figures</a> / <a
href="https://drive.google.com/uc?export=download&id=1aMbI6iCuUvOywqk5pBOmppJu1L1anqsM"> SVG Figures</a>
/
<a href="https://docs.google.com/presentation/d/1A-lBGv3NHl4L32NvfFgy1EKeSwY-0UeB/edit?usp=drive_link&ouid=110441678248547154185&rtpof=true&sd=true">
PowerPoint Figures</a>
<li> Chapter 15 - Generative adversarial networks: <a
href="https://github.com/udlbook/udlbook/raw/main/PDFFigures/UDLChap15PDF.zip">PDF Figures</a> / <a
href="https://drive.google.com/uc?export=download&id=1EErnlZCOlXc3HK7m83T2Jh_0NzIUHvtL"> SVG Figures</a>
/
<a href="https://docs.google.com/presentation/d/10Ernk41ShOTf4IYkMD-l4dJfKATkXH4w/edit?usp=drive_link&ouid=110441678248547154185&rtpof=true&sd=true">PowerPoint
Figures</a>
<li> Chapter 16 - Normalizing flows: <a
href="https://github.com/udlbook/udlbook/raw/main/PDFFigures/UDLChap16PDF.zip">PDF Figures</a> / <a
href="https://drive.google.com/uc?export=download&id=1B9bxtmdugwtg-b7Y4AdQKAIEVWxjx8l3"> SVG Figures</a>
/
<a href="https://docs.google.com/presentation/d/1nLLzqb9pdfF_h6i1HUDSyp7kSMIkSUUA/edit?usp=drive_link&ouid=110441678248547154185&rtpof=true&sd=true">PowerPoint
Figures</a>
<li> Chapter 17 - Variational autoencoders: <a
href="https://github.com/udlbook/udlbook/raw/main/PDFFigures/UDLChap17PDF.zip">PDF Figures</a> / <a
href="https://drive.google.com/uc?export=download&id=1SNtNIY7khlHQYMtaOH-FosSH3kWwL4b7"> SVG Figures</a>
/
<a href="https://docs.google.com/presentation/d/1lQE4Bu7-LgvV2VlJOt_4dQT-kusYl7Vo/edit?usp=drive_link&ouid=110441678248547154185&rtpof=true&sd=true">PowerPoint
Figures</a>
<li> Chapter 18 - Diffusion models: <a
href="https://github.com/udlbook/udlbook/raw/main/PDFFigures/UDLChap18PDF.zip">PDF Figures</a> / <a
href="https://drive.google.com/uc?export=download&id=1A-pIGl4PxjVMYOKAUG3aT4a8wD3G-q_r"> SVG Figures</a>
/
<a href="https://docs.google.com/presentation/d/1x_ufIBtVPzWUvRieKMkpw5SdRjXWwdfR/edit?usp=drive_link&ouid=110441678248547154185&rtpof=true&sd=true">
PowerPoint Figures</a>
<li> Chapter 19 - Deep reinforcement learning: <a
href="https://github.com/udlbook/udlbook/raw/main/PDFFigures/UDLChap19PDF.zip">PDF Figures</a> / <a
href="https://drive.google.com/uc?export=download&id=1a5WUoF7jeSgwC_PVdckJi1Gny46fCqh0"> SVG Figures</a>
/
<a href="https://docs.google.com/presentation/d/1TnYmVbFNhmMFetbjyfXGmkxp1EHauMqr/edit?usp=drive_link&ouid=110441678248547154185&rtpof=true&sd=true">
PowerPoint Figures </a>
<li> Chapter 20 - Why does deep learning work?: <a
href="https://github.com/udlbook/udlbook/raw/main/PDFFigures/UDLChap20PDF.zip">PDF Figures</a> / <a
href="https://drive.google.com/uc?export=download&id=1M2d0DHEgddAQoIedKSDTTt7m1ZdmBLQ3"> SVG Figures</a>
/
<a href="https://docs.google.com/presentation/d/1coxF4IsrCzDTLrNjRagHvqB_FBy10miA/edit?usp=drive_link&ouid=110441678248547154185&rtpof=true&sd=true">
PowerPoint Figures</a>
<li> Chapter 21 - Deep learning and ethics: <a
href="https://github.com/udlbook/udlbook/raw/main/PDFFigures/UDLChap21PDF.zip">PDF Figures</a> / <a
href="https://drive.google.com/uc?export=download&id=1jixmFfwmZkW_UVYzcxmDcMsdFFtnZ0bU"> SVG Figures</a>/
<a
href="https://docs.google.com/presentation/d/1EtfzanZYILvi9_-Idm28zD94I_6OrN9R/edit?usp=drive_link&ouid=110441678248547154185&rtpof=true&sd=true">PowerPoint
Figures</a>
<li> Appendices - <a href="https://github.com/udlbook/udlbook/raw/main/PDFFigures/UDLAppendixPDF.zip">PDF
Figures</a> / <a href="https://drive.google.com/uc?export=download&id=1k2j7hMN40ISPSg9skFYWFL3oZT7r8v-l">
SVG
Figures</a> / <a
href="https://docs.google.com/presentation/d/1_2cJHRnsoQQHst0rwZssv-XH4o5SEHks/edit?usp=drive_link&ouid=110441678248547154185&rtpof=true&sd=true">Powerpoint
Figures</a>
</ul>
Instructions for editing figures / equations can be found <a
href="https://drive.google.com/file/d/1T_MXXVR4AfyMnlEFI-UVDh--FXI5deAp/view?usp=sharing">here</a>.
<p> My slides for 20 lecture undergraduate deep learning course:</p>
<ul>
<li><a href="https://drive.google.com/uc?export=download&id=17RHb11BrydOvxSFNbRIomE1QKLVI087m">1. Introduction</a></li>
<li><a href="https://drive.google.com/uc?export=download&id=1491zkHULC7gDfqlV6cqUxyVYXZ-de-Ub">2. Supervised Learning</a></li>
<li><a href="https://drive.google.com/uc?export=download&id=1XkP1c9EhOBowla1rT1nnsDGMf2rZvrt7">3. Shallow Neural Networks</a></li>
<li><a href="https://drive.google.com/uc?export=download&id=1e2ejfZbbfMKLBv0v-tvBWBdI8gO3SSS1">4. Deep Neural Networks</a></li>
<li><a href="https://drive.google.com/uc?export=download&id=1fxQ_a1Q3eFPZ4kPqKbak6_emJK-JfnRH">5. Loss Functions</a></li>
<li><a href="https://drive.google.com/uc?export=download&id=17QQ5ZzXBtR_uCNCUU1gPRWWRUeZN9exW">6. Fitting Models</a></li>
<li><a href="https://drive.google.com/uc?export=download&id=1hC8JUCOaFWiw3KGn0rm7nW6mEq242QDK">7. Computing Gradients</a></li>
<li><a href="https://drive.google.com/uc?export=download&id=1tSjCeAVg0JCeBcPgDJDbi7Gg43Qkh9_d">7b. Initialization</a></li>
<li><a href="https://drive.google.com/uc?export=download&id=1RVZW3KjEs0vNSGx3B2fdizddlr6I0wLl">8. Performance</a></li>
<li><a href="https://drive.google.com/uc?export=download&id=1LTicIKPRPbZRkkg6qOr1DSuOB72axood">9. Regularization</a></li>
<li><a href="https://drive.google.com/uc?export=download&id=1bGVuwAwrofzZdfvj267elIzkYMIvYFj0">10. Convolutional Networks</a></li>
<li><a href="https://drive.google.com/uc?export=download&id=14w31QqWRDix1GdUE-na0_E0kGKBhtKzs">11. Image Generation</a></li>
<li><a href="https://drive.google.com/uc?export=download&id=1af6bTTjAbhDYfrDhboW7Fuv52Gk9ygKr">12. Transformers and LLMs</a></li>
</ul>
<h2>Resources for students</h2>
<p>Answers to selected questions: <a
href="https://github.com/udlbook/udlbook/raw/main/UDL_Answer_Booklet_Students.pdf">PDF</a>
</p>
<p>Python notebooks: (Early ones more thoroughly tested than later ones!)</p>
<ul>
<li> Notebook 1.1 - Background mathematics: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap01/1_1_BackgroundMathematics.ipynb">ipynb/colab</a>
</li>
<li> Notebook 2.1 - Supervised learning: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap02/2_1_Supervised_Learning.ipynb">ipynb/colab</a>
</li>
<li> Notebook 3.1 - Shallow networks I: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap03/3_1_Shallow_Networks_I.ipynb">ipynb/colab </a>
</li>
<li> Notebook 3.2 - Shallow networks II: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap03/3_2_Shallow_Networks_II.ipynb">ipynb/colab </a>
</li>
<li> Notebook 3.3 - Shallow network regions: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap03/3_3_Shallow_Network_Regions.ipynb">ipynb/colab </a>
</li>
<li> Notebook 3.4 - Activation functions: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap03/3_4_Activation_Functions.ipynb">ipynb/colab </a>
</li>
<li> Notebook 4.1 - Composing networks: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap04/4_1_Composing_Networks.ipynb">ipynb/colab </a>
</li>
<li> Notebook 4.2 - Clipping functions: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap04/4_2_Clipping_functions.ipynb">ipynb/colab </a>
</li>
<li> Notebook 4.3 - Deep networks: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap04/4_3_Deep_Networks.ipynb">ipynb/colab </a>
</li>
<li> Notebook 5.1 - Least squares loss: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap05/5_1_Least_Squares_Loss.ipynb">ipynb/colab </a>
</li>
<li> Notebook 5.2 - Binary cross-entropy loss: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap05/5_2_Binary_Cross_Entropy_Loss.ipynb">ipynb/colab </a>
</li>
<li> Notebook 5.3 - Multiclass cross-entropy loss: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap05/5_3_Multiclass_Cross_entropy_Loss.ipynb">ipynb/colab </a>
</li>
<li> Notebook 6.1 - Line search: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap06/6_1_Line_Search.ipynb">ipynb/colab </a>
</li>
<li> Notebook 6.2 - Gradient descent: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap06/6_2_Gradient_Descent.ipynb">ipynb/colab </a>
</li>
<li> Notebook 6.3 - Stochastic gradient descent: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap06/6_3_Stochastic_Gradient_Descent.ipynb">ipynb/colab </a>
</li>
<li> Notebook 6.4 - Momentum: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap06/6_4_Momentum.ipynb">ipynb/colab </a>
</li>
<li> Notebook 6.5 - Adam: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap06/6_5_Adam.ipynb">ipynb/colab </a>
</li>
<li> Notebook 7.1 - Backpropagation in toy model: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap07/7_1_Backpropagation_in_Toy_Model.ipynb">ipynb/colab </a>
</li>
<li> Notebook 7.2 - Backpropagation: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap07/7_2_Backpropagation.ipynb">ipynb/colab </a>
</li>
<li> Notebook 7.3 - Initialization: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap07/7_3_Initialization.ipynb">ipynb/colab </a>
</li>
<li> Notebook 8.1 - MNIST-1D performance: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap08/8_1_MNIST_1D_Performance.ipynb">ipynb/colab </a>
</li>
<li> Notebook 8.2 - Bias-variance trade-off: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap08/8_2_Bias_Variance_Trade_Off.ipynb">ipynb/colab </a>
</li>
<li> Notebook 8.3 - Double descent: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap08/8_3_Double_Descent.ipynb">ipynb/colab </a>
</li>
<li> Notebook 8.4 - High-dimensional spaces: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap08/8_4_High_Dimensional_Spaces.ipynb">ipynb/colab </a>
</li>
<li> Notebook 9.1 - L2 regularization: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap09/9_1_L2_Regularization.ipynb">ipynb/colab </a>
</li>
<li> Notebook 9.2 - Implicit regularization: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap09/9_2_Implicit_Regularization.ipynb">ipynb/colab </a>
</li>
<li> Notebook 9.3 - Ensembling: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap09/9_3_Ensembling.ipynb">ipynb/colab </a>
</li>
<li> Notebook 9.4 - Bayesian approach: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap09/9_4_Bayesian_Approach.ipynb">ipynb/colab </a>
</li>
<li> Notebook 9.5 - Augmentation <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap09/9_5_Augmentation.ipynb">ipynb/colab </a>
</li>
<li> Notebook 10.1 - 1D convolution: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap10/10_1_1D_Convolution.ipynb">ipynb/colab </a>
</li>
<li> Notebook 10.2 - Convolution for MNIST-1D: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap10/10_2_Convolution_for_MNIST_1D.ipynb">ipynb/colab </a>
</li>
<li> Notebook 10.3 - 2D convolution: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap10/10_3_2D_Convolution.ipynb">ipynb/colab </a>
</li>
<li> Notebook 10.4 - Downsampling & upsampling: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap10/10_4_Downsampling_and_Upsampling.ipynb">ipynb/colab </a>
</li>
<li> Notebook 10.5 - Convolution for MNIST: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap10/10_5_Convolution_For_MNIST.ipynb">ipynb/colab </a>
</li>
<li> Notebook 11.1 - Shattered gradients: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap11/11_1_Shattered_Gradients.ipynb">ipynb/colab </a>
</li>
<li> Notebook 11.2 - Residual networks: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap11/11_2_Residual_Networks.ipynb">ipynb/colab </a>
</li>
<li> Notebook 11.3 - Batch normalization: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap11/11_3_Batch_Normalization.ipynb">ipynb/colab </a>
</li>
<li> Notebook 12.1 - Self-attention: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap12/12_1_Self_Attention.ipynb">ipynb/colab </a>
</li>
<li> Notebook 12.2 - Multi-head self-attention: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap12/12_2_Multihead_Self_Attention.ipynb">ipynb/colab </a>
</li>
<li> Notebook 12.3 - Tokenization: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap12/12_3_Tokenization.ipynb">ipynb/colab </a>
</li>
<li> Notebook 12.4 - Decoding strategies: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap12/12_4_Decoding_Strategies.ipynb">ipynb/colab </a>
</li>
<li> Notebook 13.1 - Encoding graphs: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap13/13_1_Graph_Representation.ipynb">ipynb/colab </a>
</li>
<li> Notebook 13.2 - Graph classification : <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap13/13_2_Graph_Classification.ipynb">ipynb/colab </a>
</li>
<li> Notebook 13.3 - Neighborhood sampling: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap13/13_3_Neighborhood_Sampling.ipynb">ipynb/colab </a>
</li>
<li> Notebook 13.4 - Graph attention: <a
href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap13/13_4_Graph_Attention_Networks.ipynb">ipynb/colab </a>
</li>
<li> Notebook 15.1 - GAN toy example: <a href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap15/15_1_GAN_Toy_Example.ipynb">ipynb/colab </a></li>
<li> Notebook 15.2 - Wasserstein distance: <a href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap15/15_2_Wasserstein_Distance.ipynb">ipynb/colab </a></li>
<li> Notebook 16.1 - 1D normalizing flows: <a href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap16/16_1_1D_Normalizing_Flows.ipynb">ipynb/colab </a></li>
<li> Notebook 16.2 - Autoregressive flows: <a href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap16/16_2_Autoregressive_Flows.ipynb">ipynb/colab </a></li>
<li> Notebook 16.3 - Contraction mappings: <a href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap16/16_3_Contraction_Mappings.ipynb">ipynb/colab </a></li>
<li> Notebook 17.1 - Latent variable models: <a href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap17/17_1_Latent_Variable_Models.ipynb">ipynb/colab </a></li>
<li> Notebook 17.2 - Reparameterization trick: <a href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap17/17_2_Reparameterization_Trick.ipynb">ipynb/colab </a></li>
<li> Notebook 17.3 - Importance sampling: <a href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap17/17_3_Importance_Sampling.ipynb">ipynb/colab </a></li>
<li> Notebook 18.1 - Diffusion encoder: <a href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap18/18_1_Diffusion_Encoder.ipynb">ipynb/colab </a></li>
<li> Notebook 18.2 - 1D diffusion model: <a href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap18/18_2_1D_Diffusion_Model.ipynb">ipynb/colab </a></li>
<li> Notebook 18.3 - Reparameterized model: <a href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap18/18_3_Reparameterized_Model.ipynb">ipynb/colab </a></li>
<li> Notebook 18.4 - Families of diffusion models: <a href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap18/18_4_Families_of_Diffusion_Models.ipynb">ipynb/colab </a></li>
<li> Notebook 19.1 - Markov decision processes: <a href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap19/19_1_Markov_Decision_Processes.ipynb">ipynb/colab </a></li>
<li> Notebook 19.2 - Dynamic programming: <a href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap19/19_2_Dynamic_Programming.ipynb">ipynb/colab </a></li>
<li> Notebook 19.3 - Monte-Carlo methods: <a href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap19/19_3_Monte_Carlo_Methods.ipynb">ipynb/colab </a></li>
<li> Notebook 19.4 - Temporal difference methods: <a href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap19/19_4_Temporal_Difference_Methods.ipynb">ipynb/colab </a></li>
<li> Notebook 19.5 - Control variates: <a href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap19/19_5_Control_Variates.ipynb">ipynb/colab </a></li>
<li> Notebook 20.1 - Random data: <a href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap20/20_1_Random_Data.ipynb">ipynb/colab </a></li>
<li> Notebook 20.2 - Full-batch gradient descent: <a href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap20/20_2_Full_Batch_Gradient_Descent.ipynb">ipynb/colab </a></li>
<li> Notebook 20.3 - Lottery tickets: <a href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap20/20_3_Lottery_Tickets.ipynb">ipynb/colab </a></li>
<li> Notebook 20.4 - Adversarial attacks: <a href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap20/20_4_Adversarial_Attacks.ipynb">ipynb/colab </a></li>
<li> Notebook 21.1 - Bias mitigation: <a href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap21/21_1_Bias_Mitigation.ipynb">ipynb/colab </a></li>
<li> Notebook 21.2 - Explainability: <a href="https://github.com/udlbook/udlbook/blob/main/Notebooks/Chap21/21_2_Explainability.ipynb">ipynb/colab </a></li>
</ul>
<br>
<h2>Citation</h2>
<pre><code>
@book{prince2023understanding,
author = "Simon J.D. Prince",
title = "Understanding Deep Learning",
publisher = "MIT Press",
year = 2023,
url = "http://udlbook.com"
}
</code></pre>
</div>
</body>

8
jsconfig.json Normal file
View File

@@ -0,0 +1,8 @@
{
"compilerOptions": {
"baseUrl": "./",
"paths": {
"@/*": ["src/*"]
}
}
}

22795
package-lock.json generated Executable file → Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,50 +1,36 @@
{ {
"name": "react-website-smooth-scroll", "name": "udlbook-website",
"version": "0.1.0", "version": "0.1.0",
"private": true, "private": true,
"homepage": "https://udlbook.github.io/udlbook/", "homepage": "https://udlbook.github.io/udlbook",
"dependencies": { "type": "module",
"@fortawesome/fontawesome-svg-core": "^6.5.1",
"@testing-library/jest-dom": "^5.15.1",
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^12.8.3",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-icons": "^5.0.1",
"react-router-dom": "^6.0.2",
"react-scripts": "4.0.3",
"react-scroll": "^1.8.4",
"styled-components": "^5.3.3",
"url-loader": "^4.1.1",
"web-vitals": "^1.1.2"
},
"scripts": { "scripts": {
"start": "react-scripts --openssl-legacy-provider start", "dev": "vite",
"build": "react-scripts --openssl-legacy-provider build", "build": "vite build",
"test": "react-scripts test", "preview": "vite preview",
"eject": "react-scripts eject", "lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
"predeploy": "npm run build", "predeploy": "npm run build",
"deploy": "gh-pages -d build" "deploy": "gh-pages -d dist",
"clean": "rm -rf node_modules dist",
"format": "prettier --write ."
}, },
"eslintConfig": { "dependencies": {
"extends": [ "react": "^18.3.1",
"react-app", "react-dom": "^18.3.1",
"react-app/jest" "react-icons": "^5.2.1",
] "react-router-dom": "^6.23.1",
}, "react-scroll": "^1.8.4",
"browserslist": { "styled-components": "^6.1.11"
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}, },
"devDependencies": { "devDependencies": {
"gh-pages": "^6.1.1" "@vitejs/plugin-react-swc": "^3.5.0",
"eslint": "^8.57.0",
"eslint-plugin-react": "^7.34.2",
"eslint-plugin-react-hooks": "^4.6.2",
"eslint-plugin-react-refresh": "^0.4.7",
"gh-pages": "^6.1.1",
"prettier": "^3.3.1",
"prettier-plugin-organize-imports": "^3.2.4",
"vite": "^5.2.12"
} }
} }

BIN
public/NMI_Review.pdf Normal file

Binary file not shown.

BIN
public/favicon.ico Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@@ -1,46 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Encode+Sans+Expanded:wght@400;700&display=swap" rel="stylesheet">
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.4 KiB

View File

@@ -1,25 +0,0 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}

View File

@@ -1,3 +0,0 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:

View File

@@ -1,6 +0,0 @@
*{
box-sizing: border-box;
margin: 0;
padding: 0 ;
font-family: 'Encode Sans Expanded', sans-serif;
}

View File

@@ -1,19 +0,0 @@
import './App.css';
import {BrowserRouter as Router, Routes, Route} from 'react-router-dom'
import Home from './pages';
function App() {
return (
<Router>
<Routes>
<Route exact path="/" element ={<Home/>} />
</Routes>
</Router>
);
}
export default App;

12
src/App.jsx Executable file
View File

@@ -0,0 +1,12 @@
import Index from "@/pages";
import { BrowserRouter as Router, Route, Routes } from "react-router-dom";
export default function App() {
return (
<Router>
<Routes>
<Route exact path="/udlbook" element={<Index />} />
</Routes>
</Router>
);
}

34
src/README.md Normal file
View File

@@ -0,0 +1,34 @@
# Understanding Deep Learning
Understanding Deep Learning - Simon J.D. Prince
## Website
```shell
# Install dependencies
npm install
# Run the website in development mode
npm dev
# Build the website
npm build
# Preview the built website
npm preview
# Format the code
npm run format
# Lint the code
npm run lint
# Clean the repository
npm run clean
# Prepare to deploy the website
npm run predeploy
# Deploy the website
npm run deploy
```

View File

@@ -1,23 +0,0 @@
import styled from 'styled-components'
import {Link} from 'react-scroll'
export const Button= styled(Link)`
border-radius: 50px;
background: ${({primary}) => (primary ? '#01BF71' : '#010606')};
white-space: nowrap;
padding: ${({big}) => (big? ' 14px 48px': '12px 30px')};
color: ${({dark}) => (dark ? '#010106': '#fff')};
font-size: $${({fontBig}) => (fontBig ? '20px' : '16px')};
outline: none;
border: none;
cursor: pointer;
display: flex;
justify-content: center;
align-items: center;
transition: all 0.2s ease-in-out;
&:hover {
transition: all 0.2s ease-in-out;
background: ${({primary}) => (primary ? '#fff' : '#01BF71')}
}
`

View File

@@ -1,9 +1,9 @@
import styled from 'styled-components' import { Link } from "react-router-dom";
import {Link} from 'react-router-dom' import styled from "styled-components";
export const FooterContainer = styled.footer` export const FooterContainer = styled.footer`
background-color: #101522; background-color: #101522;
` `;
export const FooterWrap = styled.div` export const FooterWrap = styled.div`
padding: 48x 24px; padding: 48x 24px;
@@ -13,7 +13,7 @@ export const FooterWrap = styled.div`
align-items: center; align-items: center;
max-width: 1100px; max-width: 1100px;
margin: 0 auto; margin: 0 auto;
` `;
export const FooterLinksContainer = styled.div` export const FooterLinksContainer = styled.div`
display: flex; display: flex;
@@ -22,14 +22,15 @@ export const FooterLinksContainer = styled.div`
@media screen and (max-width: 820px) { @media screen and (max-width: 820px) {
padding-top: 32px; padding-top: 32px;
} }
` `;
export const FooterLinksWrapper = styled.div` export const FooterLinksWrapper = styled.div`
display: flex; display: flex;
@media screen and (max-width: 820px) { @media screen and (max-width: 820px) {
flex-direction: column; flex-direction: column;
} }
` `;
export const FooterLinkItems = styled.div` export const FooterLinkItems = styled.div`
display: flex; display: flex;
@@ -46,12 +47,12 @@ export const FooterLinkItems = styled.div`
padding: 10px; padding: 10px;
width: 100%; width: 100%;
} }
` `;
export const FooterLinkTitle = styled.h1` export const FooterLinkTitle = styled.h1`
font-size: 14px; font-size: 14px;
margin-bottom: 16px; margin-bottom: 16px;
` `;
export const FooterLink = styled(Link)` export const FooterLink = styled(Link)`
color: #ffffff; color: #ffffff;
@@ -63,12 +64,12 @@ export const FooterLink = styled(Link)`
color: #01bf71; color: #01bf71;
transition: 0.3s ease-in-out; transition: 0.3s ease-in-out;
} }
` `;
export const SocialMedia = styled.section` export const SocialMedia = styled.section`
max-width: 1000px; max-width: 1000px;
width: 100%; width: 100%;
` `;
export const SocialMediaWrap = styled.div` export const SocialMediaWrap = styled.div`
display: flex; display: flex;
@@ -80,7 +81,7 @@ export const SocialMediaWrap = styled.div`
@media screen and (max-width: 820px) { @media screen and (max-width: 820px) {
flex-direction: column; flex-direction: column;
} }
` `;
export const SocialAttrWrap = styled.div` export const SocialAttrWrap = styled.div`
color: #fff; color: #fff;
@@ -93,7 +94,7 @@ export const SocialAttrWrap = styled.div`
@media screen and (max-width: 820px) { @media screen and (max-width: 820px) {
flex-direction: column; flex-direction: column;
} }
` `;
export const SocialLogo = styled(Link)` export const SocialLogo = styled(Link)`
color: #fff; color: #fff;
@@ -105,12 +106,16 @@ export const SocialLogo = styled(Link)`
align-items: center; align-items: center;
margin-bottom: 16px; margin-bottom: 16px;
font-weight: bold; font-weight: bold;
`
@media screen and (max-width: 768px) {
font-size: 20px;
}
`;
export const WebsiteRights = styled.small` export const WebsiteRights = styled.small`
color: #fff; color: #fff;
margin-bottom: 8px; margin-bottom: 8px;
` `;
export const SocialIcons = styled.div` export const SocialIcons = styled.div`
display: flex; display: flex;
@@ -118,17 +123,18 @@ export const SocialIcons = styled.div`
align-items: center; align-items: center;
width: 60px; width: 60px;
margin-bottom: 8px; margin-bottom: 8px;
` `;
export const SocialIconLink = styled.a` export const SocialIconLink = styled.a`
color: #fff; color: #fff;
font-size: 24px; font-size: 24px;
` margin-right: 8px;
`;
export const FooterImgWrap = styled.div` export const FooterImgWrap = styled.div`
max-width: 555px; max-width: 555px;
height: 100%; height: 100%;
` `;
export const FooterImg = styled.img` export const FooterImg = styled.img`
width: 100%; width: 100%;

View File

@@ -1,42 +0,0 @@
import React from 'react'
import { FaLinkedin} from 'react-icons/fa'
import { FooterContainer, FooterWrap, FooterImg } from './FooterElements'
import { SocialMedia, SocialMediaWrap, SocialIcons, SocialIconLink, WebsiteRights, SocialLogo } from './FooterElements'
import { animateScroll as scroll } from 'react-scroll'
import twitterImg from '../../images/square-x-twitter.svg'
const Footer = () => {
const toggleHome = () => {
scroll.scrollToTop();
}
return (
<>
<FooterContainer>
<FooterWrap>
<SocialMedia>
<SocialMediaWrap>
<SocialLogo to='/' onClick={toggleHome}>
Understanding Deep Learning
</SocialLogo>
<WebsiteRights>©{new Date().getFullYear()} Simon J.D. Prince</WebsiteRights>
<WebsiteRights>
Images by StorySet on FreePik: <a href="https://www.freepik.com/free-vector/hand-coding-concept-illustration_21864184.htm#query=coding&position=17&from_view=search&track=sph&uuid=5896d847-38e4-4cb9-8fe1-103041c7c933"> [1] </a> <a href="https://www.freepik.com/free-vector/mathematics-concept-illustration_10733824.htm#query=professor&position=13&from_view=search&track=sph&uuid=5b1a188a-64c5-45af-aae2-8573bc1bed3c">[2]</a> <a href="https://www.freepik.com/free-vector/content-concept-illustration_7171429.htm#query=media&position=3&from_view=search&track=sph&uuid=c7e35cf2-d85d-4bba-91a6-1cd883dcf153"> [3]</a> <a href="https://www.freepik.com/free-vector/library-concept-illustration_9148008.htm#query=library&position=40&from_view=search&track=sph&uuid=abecc792-b6b2-4ec0-b318-5e6cc73ba649"> [4]</a>
</WebsiteRights>
<SocialIcons>
<SocialIconLink href="https://twitter.com/SimonPrinceAI" target="_blank" aria-label="Twitter">
<FooterImg src={twitterImg} alt="twitter"/>
</SocialIconLink>
<SocialIconLink href="https://www.linkedin.com/in/simon-prince-615bb9165/" target="_blank" aria-label="LinkedIn">
<FaLinkedin/>
</SocialIconLink>
</SocialIcons>
</SocialMediaWrap>
</SocialMedia>
</FooterWrap>
</FooterContainer>
</>
)
}
export default Footer

84
src/components/Footer/index.jsx Executable file
View File

@@ -0,0 +1,84 @@
import {
FooterContainer,
FooterWrap,
SocialIconLink,
SocialIcons,
SocialLogo,
SocialMedia,
SocialMediaWrap,
WebsiteRights,
} from "@/components/Footer/FooterElements";
import { FaGithub, FaLinkedin } from "react-icons/fa";
import { FaSquareXTwitter } from "react-icons/fa6";
import { animateScroll as scroll } from "react-scroll";
const images = [
"https://freepik.com/free-vector/hand-coding-concept-illustration_21864184.htm#query=coding&position=17&from_view=search&track=sph&uuid=5896d847-38e4-4cb9-8fe1-103041c7c933",
"https://freepik.com/free-vector/mathematics-concept-illustration_10733824.htm#query=professor&position=13&from_view=search&track=sph&uuid=5b1a188a-64c5-45af-aae2-8573bc1bed3c",
"https://freepik.com/free-vector/content-concept-illustration_7171429.htm#query=media&position=3&from_view=search&track=sph&uuid=c7e35cf2-d85d-4bba-91a6-1cd883dcf153",
"https://freepik.com/free-vector/library-concept-illustration_9148008.htm#query=library&position=40&from_view=search&track=sph&uuid=abecc792-b6b2-4ec0-b318-5e6cc73ba649",
];
const socials = [
{
href: "https://twitter.com/SimonPrinceAI",
icon: FaSquareXTwitter,
alt: "Twitter",
},
{
href: "https://linkedin.com/in/simon-prince-615bb9165/",
icon: FaLinkedin,
alt: "LinkedIn",
},
{
href: "https://github.com/udlbook/udlbook",
icon: FaGithub,
alt: "GitHub",
},
];
export default function Footer() {
const scrollToHome = () => {
scroll.scrollToTop();
};
return (
<>
<FooterContainer>
<FooterWrap>
<SocialMedia>
<SocialMediaWrap>
<SocialLogo to="/udlbook" onClick={scrollToHome}>
Understanding Deep Learning
</SocialLogo>
<WebsiteRights>
&copy; {new Date().getFullYear()} Simon J.D. Prince
</WebsiteRights>
<WebsiteRights>
Images by StorySet on FreePik:{" "}
{images.map((image, index) => (
<a key={index} href={image}>
[{index + 1}]
</a>
))}
</WebsiteRights>
<SocialIcons>
{socials.map((social, index) => (
<SocialIconLink
key={index}
href={social.href}
target="_blank"
aria-label={social.alt}
alt={social.alt}
>
<social.icon />
</SocialIconLink>
))}
</SocialIcons>
</SocialMediaWrap>
</SocialMedia>
</FooterWrap>
</FooterContainer>
</>
);
}

View File

@@ -1,242 +0,0 @@
import styled from "styled-components";
export const HeroContainer = styled.div`
background: #57c6d1;
display: flex;
justify-content: center;
align-items: center;
padding: 0 0px;
position: static;
z-index: 1;
}
`
export const HeroContent = styled.div`
z-index: 3;
width: 100% ;
max-width: 1100px;
position: static;
padding: 8px 24px;
margin: 80px 0px;
display: flex;
flex-direction: column;
align-items: center ;
`
export const HeroH1 = styled.h1`
color: #fff;
font-size: 48px;
text-align: center;
@media screen and (max-width: 768px) {
font-size: 40px;
}
@media screen and (max-width: 480px) {
font-size: 32px;
}
`
export const HeroP = styled.p`
margin-top: 24px;
color: #fff;
font-size: 24px ;
text-align: center ;
max-width: 600px ;
@media screen and (max-width: 768px) {
font-size: 24px;
}
@media screen and (max-width: 480px) {
font-size: 18px;
}
`
export const HeroBtnWrapper = styled.div`
margin-top: 32px ;
display: flex;
flex-direction: column ;
align-items: center ;
`
export const HeroRow = styled.div`
display: grid;
grid-auto-columns: minmax(auto, 1fr);
align-items: top;
grid-template-areas: 'col1 col2' };
@media screen and (max-width: 768px){
grid-template-areas: 'col2' 'col1';
}
`
export const HeroNewsItem = styled.div`
margin-left: 4px;
color: #000000;
font-size: 16px;
// line-height: 16px;
margin-bottom: 16px;
display: flex;
justify-content: start;
`
export const HeroNewsItemDate = styled.div`
width: 20%;
font-size: 16px ;
margin-right: 20px ;
@media screen and (max-width: 768px) {
font-size: 24px;
}
@media screen and (max-width: 480px) {
font-size: 18px;
}
`
export const HeroNewsItemContent = styled.div`
width: 80%;
color: #000000;
font-size: 16px ;
@media screen and (max-width: 768px) {
font-size: 24px;
}
@media screen and (max-width: 480px) {
font-size: 18px;
}
`
export const HeroColumn1 = styled.div`
margin-bottom: 15px;
margin-left: 12px;
margin-top: 60px;
padding: 10px 15px;
padding: 0 15px;
grid-area: col1;
align-items:left;
display: flex;
flex-direction:column;
justify-content: space-between;
`
export const HeroColumn2 = styled.div`
margin-bottom: 15px;
padding: 0 15px;
grid-area: col2;
display: flex;
align-items:center;
flex-direction:column;
`
export const TextWrapper = styled.div`
max-width: 540px ;
padding-top: 0;
padding-bottom: 0;
`
export const HeroImgWrap = styled.div`
max-width: 555px;
height: 100%;
`
export const Img = styled.img`
width: 100%;
margin-top: 0;
margin-right: 0;
margin-left: 10px;
padding-right: 0;
`;
export const HeroDownloadsImg = styled.img`
margin-top: 5px;
margin-right: 0;
margin-left: 0;
padding-right: 0;
margin-bottom: 10px;
`
export const HeroLink = styled.a`
color: #fff;
text-decoration: none;
padding: 0.1rem 0rem;
height: 100%;
cursor: pointer;
&:hover {
filter: brightness(0.85);
}
&.active {
color: #000
border-bottom: 3px solid #01bf71;
}
`;
export const HeroNewsTitle = styled.div`
margin-left: 0px;
color: #000000;
font-size: 16px;
font-weight: bold;
line-height: 16px;
margin-bottom: 36px;
@media screen and (max-width: 768px) {
font-size: 24px;
}
@media screen and (max-width: 480px) {
font-size: 18px;
}
`
export const HeroCitationTitle = styled.div`
margin-left: 0px;
color: #000000;
font-size: 16px;
font-weight: bold;
line-height: 16px;
margin-bottom: 10px;
margin-top:36px;
@media screen and (max-width: 768px) {
font-size: 24px;
}
@media screen and (max-width: 480px) {
font-size: 18px;
}
`
export const HeroNewsBlock = styled.div`
`
export const HeroCitationBlock = styled.div`
font-size: 14px;
margin-bottom: 0px;
margin-top: 0px;
`
export const HeroFollowBlock = styled.div`
@media screen and (max-width: 768px) {
font-size: 24px;
}
@media screen and (max-width: 480px) {
font-size: 18px;
}
`

Some files were not shown because too many files have changed in this diff Show More