diff --git a/doc/pub/week39/html/week39-bs.html b/doc/pub/week39/html/week39-bs.html index 03f5751cc..be839261c 100644 --- a/doc/pub/week39/html/week39-bs.html +++ b/doc/pub/week39/html/week39-bs.html @@ -421,7 +421,7 @@ MathJax.Hub.Config({
-

Oct 31, 2022

+

Nov 1, 2022


diff --git a/doc/pub/week39/html/week39-reveal.html b/doc/pub/week39/html/week39-reveal.html index 4e0ff1b3e..b2dd48fc5 100644 --- a/doc/pub/week39/html/week39-reveal.html +++ b/doc/pub/week39/html/week39-reveal.html @@ -184,7 +184,7 @@ MathJax.Hub.Config({
-

Oct 31, 2022

+

Nov 1, 2022


@@ -3526,9 +3526,9 @@ delta_momentum = 0.3 def CostOLS(y,X,theta): return np.sum((y-X @ theta)**2) -n = 10000 +n = 1000 x = np.random.rand(n,1) -y = 2.0+3*x +4*x*x# +np.random.randn(n,1) +y = 2.0+3*x +4*x*x X = np.c_[np.ones((n,1)), x, x*x] XT_X = X.T @ X @@ -3551,19 +3551,14 @@ eta = 0.01 # Including AdaGrad parameter to avoid possible division by zero delta = 1e-8 for epoch in range(n_epochs): - # The outer product is calculated from scratch for each epoch - Giter = np.zeros(shape=(3,3)) + Giter = 0.0 for i in range(m): random_index = M*np.random.randint(m) xi = X[random_index:random_index+M] yi = y[random_index:random_index+M] gradients = (1.0/M)*training_gradient(yi, xi, theta) - # Calculate the outer product of the gradients - Giter +=gradients @ gradients.T - # Simpler algorithm with only diagonal elements - Ginverse = np.c_[eta/(delta+np.sqrt(np.diagonal(Giter)))] - # compute update - update = np.multiply(Ginverse,gradients) + Giter += gradients*gradients + update = gradients*eta/(delta+np.sqrt(Giter)) theta -= update print("theta from own AdaGrad") print(theta) @@ -3606,7 +3601,7 @@ delta = 1e-8 def CostOLS(y,X,theta): return np.sum((y-X @ theta)**2) -n = 10000 +n = 1000 x = np.random.rand(n,1) y = 2.0+3*x +4*x*x# +np.random.randn(n,1) @@ -3633,18 +3628,18 @@ rho = 0.99 # Including AdaGrad parameter to avoid possible division by zero delta = 1e-8 for epoch in range(n_epochs): - Giter = np.zeros(shape=(3,3)) + Giter = 0.0 for i in range(m): random_index = M*np.random.randint(m) xi = X[random_index:random_index+M] yi = y[random_index:random_index+M] gradients = (1.0/M)*training_gradient(yi, xi, theta) + # Accumulated gradient # Scaling with rho the new and the previous results Giter = (rho*Giter+(1-rho)*gradients*gradients) # Taking the diagonal only and inverting - Ginverse = np.c_[eta/(delta+np.sqrt(np.diagonal(Giter)))] + update = gradients*eta/(delta+np.sqrt(Giter)) # Hadamard product - update = Ginverse*gradients theta -= update print("theta from own RMSprop") print(theta) diff --git a/doc/pub/week39/html/week39-solarized.html b/doc/pub/week39/html/week39-solarized.html index b917a62e8..5bda3166c 100644 --- a/doc/pub/week39/html/week39-solarized.html +++ b/doc/pub/week39/html/week39-solarized.html @@ -335,7 +335,7 @@ MathJax.Hub.Config({
-

Oct 31, 2022

+

Nov 1, 2022


@@ -3463,9 +3463,9 @@ delta_momentum = 0.3 def CostOLS(y,X,theta): return np.sum((y-X @ theta)**2) -n = 10000 +n = 1000 x = np.random.rand(n,1) -y = 2.0+3*x +4*x*x# +np.random.randn(n,1) +y = 2.0+3*x +4*x*x X = np.c_[np.ones((n,1)), x, x*x] XT_X = X.T @ X @@ -3488,19 +3488,14 @@ eta = 0.01 # Including AdaGrad parameter to avoid possible division by zero delta = 1e-8 for epoch in range(n_epochs): - # The outer product is calculated from scratch for each epoch - Giter = np.zeros(shape=(3,3)) + Giter = 0.0 for i in range(m): random_index = M*np.random.randint(m) xi = X[random_index:random_index+M] yi = y[random_index:random_index+M] gradients = (1.0/M)*training_gradient(yi, xi, theta) - # Calculate the outer product of the gradients - Giter +=gradients @ gradients.T - # Simpler algorithm with only diagonal elements - Ginverse = np.c_[eta/(delta+np.sqrt(np.diagonal(Giter)))] - # compute update - update = np.multiply(Ginverse,gradients) + Giter += gradients*gradients + update = gradients*eta/(delta+np.sqrt(Giter)) theta -= update print("theta from own AdaGrad") print(theta) @@ -3542,7 +3537,7 @@ delta = 1e-8 def CostOLS(y,X,theta): return np.sum((y-X @ theta)**2) -n = 10000 +n = 1000 x = np.random.rand(n,1) y = 2.0+3*x +4*x*x# +np.random.randn(n,1) @@ -3569,18 +3564,18 @@ rho = 0.99 # Including AdaGrad parameter to avoid possible division by zero delta = 1e-8 for epoch in range(n_epochs): - Giter = np.zeros(shape=(3,3)) + Giter = 0.0 for i in range(m): random_index = M*np.random.randint(m) xi = X[random_index:random_index+M] yi = y[random_index:random_index+M] gradients = (1.0/M)*training_gradient(yi, xi, theta) + # Accumulated gradient # Scaling with rho the new and the previous results Giter = (rho*Giter+(1-rho)*gradients*gradients) # Taking the diagonal only and inverting - Ginverse = np.c_[eta/(delta+np.sqrt(np.diagonal(Giter)))] + update = gradients*eta/(delta+np.sqrt(Giter)) # Hadamard product - update = Ginverse*gradients theta -= update print("theta from own RMSprop") print(theta) diff --git a/doc/pub/week39/html/week39.html b/doc/pub/week39/html/week39.html index fd81e7f3c..d3345667e 100644 --- a/doc/pub/week39/html/week39.html +++ b/doc/pub/week39/html/week39.html @@ -412,7 +412,7 @@ MathJax.Hub.Config({
-

Oct 31, 2022

+

Nov 1, 2022


@@ -3540,9 +3540,9 @@ delta_momentum = def CostOLS(y,X,theta): return np.sum((y-X @ theta)**2) -n = 10000 +n = 1000 x = np.random.rand(n,1) -y = 2.0+3*x +4*x*x# +np.random.randn(n,1) +y = 2.0+3*x +4*x*x X = np.c_[np.ones((n,1)), x, x*x] XT_X = X.T @ X @@ -3565,19 +3565,14 @@ eta = 0.01# Including AdaGrad parameter to avoid possible division by zero delta = 1e-8 for epoch in range(n_epochs): - # The outer product is calculated from scratch for each epoch - Giter = np.zeros(shape=(3,3)) + Giter = 0.0 for i in range(m): random_index = M*np.random.randint(m) xi = X[random_index:random_index+M] yi = y[random_index:random_index+M] gradients = (1.0/M)*training_gradient(yi, xi, theta) - # Calculate the outer product of the gradients - Giter +=gradients @ gradients.T - # Simpler algorithm with only diagonal elements - Ginverse = np.c_[eta/(delta+np.sqrt(np.diagonal(Giter)))] - # compute update - update = np.multiply(Ginverse,gradients) + Giter += gradients*gradients + update = gradients*eta/(delta+np.sqrt(Giter)) theta -= update print("theta from own AdaGrad") print(theta) @@ -3619,7 +3614,7 @@ delta = 1e-8def CostOLS(y,X,theta): return np.sum((y-X @ theta)**2) -n = 10000 +n = 1000 x = np.random.rand(n,1) y = 2.0+3*x +4*x*x# +np.random.randn(n,1) @@ -3646,18 +3641,18 @@ rho = 0.99# Including AdaGrad parameter to avoid possible division by zero delta = 1e-8 for epoch in range(n_epochs): - Giter = np.zeros(shape=(3,3)) + Giter = 0.0 for i in range(m): random_index = M*np.random.randint(m) xi = X[random_index:random_index+M] yi = y[random_index:random_index+M] gradients = (1.0/M)*training_gradient(yi, xi, theta) + # Accumulated gradient # Scaling with rho the new and the previous results Giter = (rho*Giter+(1-rho)*gradients*gradients) # Taking the diagonal only and inverting - Ginverse = np.c_[eta/(delta+np.sqrt(np.diagonal(Giter)))] + update = gradients*eta/(delta+np.sqrt(Giter)) # Hadamard product - update = Ginverse*gradients theta -= update print("theta from own RMSprop") print(theta) diff --git a/doc/pub/week39/ipynb/ipynb-week39-src.tar.gz b/doc/pub/week39/ipynb/ipynb-week39-src.tar.gz index 594eee531..f3e44c597 100644 Binary files a/doc/pub/week39/ipynb/ipynb-week39-src.tar.gz and b/doc/pub/week39/ipynb/ipynb-week39-src.tar.gz differ diff --git a/doc/pub/week39/ipynb/week39.ipynb b/doc/pub/week39/ipynb/week39.ipynb index 6057b1837..ba8f880bf 100644 --- a/doc/pub/week39/ipynb/week39.ipynb +++ b/doc/pub/week39/ipynb/week39.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "markdown", - "id": "fb5f2222", + "id": "e19304fc", "metadata": { "editable": true }, @@ -14,7 +14,7 @@ }, { "cell_type": "markdown", - "id": "7626a4e2", + "id": "db22c3f3", "metadata": { "editable": true }, @@ -22,14 +22,14 @@ "# Week 39: Optimization and Gradient Methods\n", "**Morten Hjorth-Jensen**, Department of Physics, University of Oslo and Department of Physics and Astronomy and Facility for Rare Isotope Beams, Michigan State University\n", "\n", - "Date: **Oct 31, 2022**\n", + "Date: **Nov 1, 2022**\n", "\n", "Copyright 1999-2022, Morten Hjorth-Jensen. Released under CC Attribution-NonCommercial 4.0 license" ] }, { "cell_type": "markdown", - "id": "4c820ce4", + "id": "70506212", "metadata": { "editable": true }, @@ -57,7 +57,7 @@ }, { "cell_type": "markdown", - "id": "a226bde2", + "id": "1317c406", "metadata": { "editable": true }, @@ -78,7 +78,7 @@ }, { "cell_type": "markdown", - "id": "080fefe2", + "id": "de988ebc", "metadata": { "editable": true }, @@ -95,7 +95,7 @@ }, { "cell_type": "markdown", - "id": "9be084a5", + "id": "c6408cd9", "metadata": { "editable": true }, @@ -110,7 +110,7 @@ }, { "cell_type": "markdown", - "id": "f05fc9f2", + "id": "5f9ddae7", "metadata": { "editable": true }, @@ -120,7 +120,7 @@ }, { "cell_type": "markdown", - "id": "8d31a5e1", + "id": "140b8948", "metadata": { "editable": true }, @@ -136,7 +136,7 @@ }, { "cell_type": "markdown", - "id": "4d08c022", + "id": "12ecdef5", "metadata": { "editable": true }, @@ -148,7 +148,7 @@ }, { "cell_type": "markdown", - "id": "40d8474b", + "id": "a84ca2bb", "metadata": { "editable": true }, @@ -159,7 +159,7 @@ }, { "cell_type": "markdown", - "id": "91d36d0b", + "id": "deef1d00", "metadata": { "editable": true }, @@ -171,7 +171,7 @@ }, { "cell_type": "markdown", - "id": "349f8798", + "id": "b46c8220", "metadata": { "editable": true }, @@ -181,7 +181,7 @@ }, { "cell_type": "markdown", - "id": "bdd74730", + "id": "94bc14f5", "metadata": { "editable": true }, @@ -195,7 +195,7 @@ }, { "cell_type": "markdown", - "id": "16ec380a", + "id": "2648c99e", "metadata": { "editable": true }, @@ -207,7 +207,7 @@ }, { "cell_type": "markdown", - "id": "1d2847b3", + "id": "df77cf5c", "metadata": { "editable": true }, @@ -217,7 +217,7 @@ }, { "cell_type": "markdown", - "id": "5083c393", + "id": "8a7e6efc", "metadata": { "editable": true }, @@ -229,7 +229,7 @@ }, { "cell_type": "markdown", - "id": "8cc7ae75", + "id": "350e1f3a", "metadata": { "editable": true }, @@ -241,7 +241,7 @@ }, { "cell_type": "markdown", - "id": "0c704002", + "id": "e02a25da", "metadata": { "editable": true }, @@ -261,7 +261,7 @@ }, { "cell_type": "markdown", - "id": "0979b7e5", + "id": "00253544", "metadata": { "editable": true }, @@ -277,7 +277,7 @@ }, { "cell_type": "markdown", - "id": "4fa81efe", + "id": "994813f7", "metadata": { "editable": true }, @@ -293,7 +293,7 @@ }, { "cell_type": "markdown", - "id": "a72f0602", + "id": "82574de2", "metadata": { "editable": true }, @@ -304,7 +304,7 @@ }, { "cell_type": "markdown", - "id": "312e71a3", + "id": "053a7486", "metadata": { "editable": true }, @@ -316,7 +316,7 @@ }, { "cell_type": "markdown", - "id": "e212d683", + "id": "527459a9", "metadata": { "editable": true }, @@ -326,7 +326,7 @@ }, { "cell_type": "markdown", - "id": "c61d2ec6", + "id": "9afae8cd", "metadata": { "editable": true }, @@ -338,7 +338,7 @@ }, { "cell_type": "markdown", - "id": "e4e17d1e", + "id": "b2dc015a", "metadata": { "editable": true }, @@ -348,7 +348,7 @@ }, { "cell_type": "markdown", - "id": "a321226a", + "id": "4a709df9", "metadata": { "editable": true }, @@ -360,7 +360,7 @@ }, { "cell_type": "markdown", - "id": "7fbca8b5", + "id": "31cfe193", "metadata": { "editable": true }, @@ -382,7 +382,7 @@ }, { "cell_type": "markdown", - "id": "a5c5f928", + "id": "cc3af9d1", "metadata": { "editable": true }, @@ -395,7 +395,7 @@ }, { "cell_type": "markdown", - "id": "dda8547c", + "id": "b0d9eaf1", "metadata": { "editable": true }, @@ -408,7 +408,7 @@ }, { "cell_type": "markdown", - "id": "a9c136b2", + "id": "1c74bd3b", "metadata": { "editable": true }, @@ -418,7 +418,7 @@ }, { "cell_type": "markdown", - "id": "3dfb3256", + "id": "7ec82113", "metadata": { "editable": true }, @@ -436,7 +436,7 @@ }, { "cell_type": "markdown", - "id": "c9646465", + "id": "ed1cfaa4", "metadata": { "editable": true }, @@ -446,7 +446,7 @@ }, { "cell_type": "markdown", - "id": "43695470", + "id": "2ac21047", "metadata": { "editable": true }, @@ -461,7 +461,7 @@ }, { "cell_type": "markdown", - "id": "7aec92b8", + "id": "2063d240", "metadata": { "editable": true }, @@ -471,7 +471,7 @@ }, { "cell_type": "markdown", - "id": "5aacc2d2", + "id": "cbf9121f", "metadata": { "editable": true }, @@ -485,7 +485,7 @@ }, { "cell_type": "markdown", - "id": "c1b231de", + "id": "978324df", "metadata": { "editable": true }, @@ -495,7 +495,7 @@ }, { "cell_type": "markdown", - "id": "3a58969a", + "id": "4b23342f", "metadata": { "editable": true }, @@ -509,7 +509,7 @@ }, { "cell_type": "markdown", - "id": "8ec5ee80", + "id": "53ae12e1", "metadata": { "editable": true }, @@ -524,7 +524,7 @@ }, { "cell_type": "markdown", - "id": "67d0192e", + "id": "2c53554c", "metadata": { "editable": true }, @@ -541,7 +541,7 @@ }, { "cell_type": "markdown", - "id": "c5413071", + "id": "934c3e8e", "metadata": { "editable": true }, @@ -553,7 +553,7 @@ }, { "cell_type": "markdown", - "id": "ad4cbada", + "id": "7fb73a2f", "metadata": { "editable": true }, @@ -567,7 +567,7 @@ }, { "cell_type": "markdown", - "id": "7f1d1d0c", + "id": "7b685426", "metadata": { "editable": true }, @@ -582,7 +582,7 @@ }, { "cell_type": "markdown", - "id": "1ec87dad", + "id": "cbbcc943", "metadata": { "editable": true }, @@ -594,7 +594,7 @@ }, { "cell_type": "markdown", - "id": "36d8f48f", + "id": "8742fc06", "metadata": { "editable": true }, @@ -605,7 +605,7 @@ }, { "cell_type": "markdown", - "id": "af64d3f3", + "id": "c94adf8d", "metadata": { "editable": true }, @@ -633,7 +633,7 @@ }, { "cell_type": "markdown", - "id": "bb5e0f73", + "id": "3d02afa9", "metadata": { "editable": true }, @@ -655,7 +655,7 @@ }, { "cell_type": "markdown", - "id": "1a121737", + "id": "20c606aa", "metadata": { "editable": true }, @@ -677,7 +677,7 @@ }, { "cell_type": "markdown", - "id": "01601485", + "id": "f858cfd5", "metadata": { "editable": true }, @@ -689,7 +689,7 @@ }, { "cell_type": "markdown", - "id": "8d354c77", + "id": "3d696476", "metadata": { "editable": true }, @@ -726,7 +726,7 @@ }, { "cell_type": "markdown", - "id": "a64e34a9", + "id": "306dee94", "metadata": { "editable": true }, @@ -754,7 +754,7 @@ }, { "cell_type": "markdown", - "id": "388506dc", + "id": "3906d87c", "metadata": { "editable": true }, @@ -784,7 +784,7 @@ }, { "cell_type": "markdown", - "id": "d6c3cefb", + "id": "5b9f50b0", "metadata": { "editable": true }, @@ -804,7 +804,7 @@ }, { "cell_type": "markdown", - "id": "bb8a0c06", + "id": "58c45902", "metadata": { "editable": true }, @@ -816,7 +816,7 @@ }, { "cell_type": "markdown", - "id": "428a2130", + "id": "e6f32e9c", "metadata": { "editable": true }, @@ -826,7 +826,7 @@ }, { "cell_type": "markdown", - "id": "a7c5391c", + "id": "f6986767", "metadata": { "editable": true }, @@ -838,7 +838,7 @@ }, { "cell_type": "markdown", - "id": "4ffaa7be", + "id": "5ca3ae5e", "metadata": { "editable": true }, @@ -850,7 +850,7 @@ }, { "cell_type": "markdown", - "id": "46f02a3c", + "id": "0df2b40b", "metadata": { "editable": true }, @@ -862,7 +862,7 @@ }, { "cell_type": "markdown", - "id": "3d4a6274", + "id": "a8951b6a", "metadata": { "editable": true }, @@ -874,7 +874,7 @@ }, { "cell_type": "markdown", - "id": "3b840107", + "id": "e57b2732", "metadata": { "editable": true }, @@ -885,7 +885,7 @@ }, { "cell_type": "markdown", - "id": "9b65c89b", + "id": "5ec1a80f", "metadata": { "editable": true }, @@ -898,7 +898,7 @@ }, { "cell_type": "markdown", - "id": "6245c0aa", + "id": "072508d4", "metadata": { "editable": true }, @@ -910,7 +910,7 @@ }, { "cell_type": "markdown", - "id": "b832719f", + "id": "dac847f4", "metadata": { "editable": true }, @@ -920,7 +920,7 @@ }, { "cell_type": "markdown", - "id": "4d0a79c9", + "id": "c3c7a46d", "metadata": { "editable": true }, @@ -932,7 +932,7 @@ }, { "cell_type": "markdown", - "id": "3500bd92", + "id": "7cff2801", "metadata": { "editable": true }, @@ -942,7 +942,7 @@ }, { "cell_type": "markdown", - "id": "35e67596", + "id": "077c7d80", "metadata": { "editable": true }, @@ -953,7 +953,7 @@ }, { "cell_type": "markdown", - "id": "d1d35ce3", + "id": "1aa22051", "metadata": { "editable": true }, @@ -965,7 +965,7 @@ }, { "cell_type": "markdown", - "id": "2231d370", + "id": "156f3fba", "metadata": { "editable": true }, @@ -977,7 +977,7 @@ }, { "cell_type": "markdown", - "id": "05b2c215", + "id": "cdb97d77", "metadata": { "editable": true }, @@ -989,7 +989,7 @@ }, { "cell_type": "markdown", - "id": "179fda60", + "id": "15a7044a", "metadata": { "editable": true }, @@ -1000,7 +1000,7 @@ }, { "cell_type": "markdown", - "id": "6083dc6b", + "id": "cbf9fdb2", "metadata": { "editable": true }, @@ -1011,7 +1011,7 @@ }, { "cell_type": "markdown", - "id": "c8a2f343", + "id": "891f4d9a", "metadata": { "editable": true }, @@ -1023,7 +1023,7 @@ }, { "cell_type": "markdown", - "id": "0f0c3a59", + "id": "e84b1a57", "metadata": { "editable": true }, @@ -1033,7 +1033,7 @@ }, { "cell_type": "markdown", - "id": "2392af5e", + "id": "8bc4b9f4", "metadata": { "editable": true }, @@ -1045,7 +1045,7 @@ }, { "cell_type": "markdown", - "id": "8d5f32b5", + "id": "facdc699", "metadata": { "editable": true }, @@ -1055,7 +1055,7 @@ }, { "cell_type": "markdown", - "id": "242bfb88", + "id": "88071807", "metadata": { "editable": true }, @@ -1067,7 +1067,7 @@ }, { "cell_type": "markdown", - "id": "3be0e98a", + "id": "7c71ee58", "metadata": { "editable": true }, @@ -1077,7 +1077,7 @@ }, { "cell_type": "markdown", - "id": "d26d8109", + "id": "f80c1bd9", "metadata": { "editable": true }, @@ -1089,7 +1089,7 @@ }, { "cell_type": "markdown", - "id": "35dca0b8", + "id": "a69a6141", "metadata": { "editable": true }, @@ -1099,7 +1099,7 @@ }, { "cell_type": "markdown", - "id": "eef08b9d", + "id": "902457d5", "metadata": { "editable": true }, @@ -1111,7 +1111,7 @@ }, { "cell_type": "markdown", - "id": "4c4615e3", + "id": "e12c7a76", "metadata": { "editable": true }, @@ -1122,7 +1122,7 @@ { "cell_type": "code", "execution_count": 1, - "id": "bc2317d3", + "id": "a085458d", "metadata": { "collapsed": false, "editable": true @@ -1155,7 +1155,7 @@ }, { "cell_type": "markdown", - "id": "ff4817d3", + "id": "9cb5bdf9", "metadata": { "editable": true }, @@ -1166,7 +1166,7 @@ { "cell_type": "code", "execution_count": 2, - "id": "1a8e357c", + "id": "251fd2a7", "metadata": { "collapsed": false, "editable": true @@ -1180,7 +1180,7 @@ }, { "cell_type": "markdown", - "id": "ad6a7c02", + "id": "64b25b67", "metadata": { "editable": true }, @@ -1191,7 +1191,7 @@ { "cell_type": "code", "execution_count": 3, - "id": "f631798e", + "id": "aeb6f371", "metadata": { "collapsed": false, "editable": true @@ -1204,7 +1204,7 @@ }, { "cell_type": "markdown", - "id": "5801b425", + "id": "97064a9e", "metadata": { "editable": true }, @@ -1215,7 +1215,7 @@ { "cell_type": "code", "execution_count": 4, - "id": "c17c4cff", + "id": "02d8c327", "metadata": { "collapsed": false, "editable": true @@ -1233,7 +1233,7 @@ }, { "cell_type": "markdown", - "id": "6a2cbdc0", + "id": "4f22e010", "metadata": { "editable": true }, @@ -1244,7 +1244,7 @@ { "cell_type": "code", "execution_count": 5, - "id": "bdf87f60", + "id": "980486c5", "metadata": { "collapsed": false, "editable": true @@ -1259,7 +1259,7 @@ }, { "cell_type": "markdown", - "id": "7877f2fd", + "id": "b814c572", "metadata": { "editable": true }, @@ -1269,7 +1269,7 @@ }, { "cell_type": "markdown", - "id": "1db449ed", + "id": "028c7b3e", "metadata": { "editable": true }, @@ -1283,7 +1283,7 @@ }, { "cell_type": "markdown", - "id": "1995f4a9", + "id": "cd289649", "metadata": { "editable": true }, @@ -1295,7 +1295,7 @@ }, { "cell_type": "markdown", - "id": "15f63d97", + "id": "adcb5d35", "metadata": { "editable": true }, @@ -1306,7 +1306,7 @@ }, { "cell_type": "markdown", - "id": "e84fa7eb", + "id": "6181d466", "metadata": { "editable": true }, @@ -1318,7 +1318,7 @@ }, { "cell_type": "markdown", - "id": "638ca172", + "id": "ff237231", "metadata": { "editable": true }, @@ -1329,7 +1329,7 @@ }, { "cell_type": "markdown", - "id": "0dc36f41", + "id": "e5d58187", "metadata": { "editable": true }, @@ -1340,7 +1340,7 @@ }, { "cell_type": "markdown", - "id": "ccc4a308", + "id": "e7ab5477", "metadata": { "editable": true }, @@ -1352,7 +1352,7 @@ }, { "cell_type": "markdown", - "id": "05962b72", + "id": "dffa1e1a", "metadata": { "editable": true }, @@ -1362,7 +1362,7 @@ }, { "cell_type": "markdown", - "id": "f4fd9df6", + "id": "35b985cd", "metadata": { "editable": true }, @@ -1374,7 +1374,7 @@ }, { "cell_type": "markdown", - "id": "31a5b2d4", + "id": "a1cd557c", "metadata": { "editable": true }, @@ -1386,7 +1386,7 @@ }, { "cell_type": "markdown", - "id": "f963d004", + "id": "13378a74", "metadata": { "editable": true }, @@ -1398,7 +1398,7 @@ }, { "cell_type": "markdown", - "id": "03e5bacf", + "id": "77acd0cf", "metadata": { "editable": true }, @@ -1410,7 +1410,7 @@ }, { "cell_type": "markdown", - "id": "bd673c40", + "id": "89382545", "metadata": { "editable": true }, @@ -1421,7 +1421,7 @@ }, { "cell_type": "markdown", - "id": "631ed22c", + "id": "efd2d8ae", "metadata": { "editable": true }, @@ -1433,7 +1433,7 @@ }, { "cell_type": "markdown", - "id": "b40cf902", + "id": "48f4c6b5", "metadata": { "editable": true }, @@ -1443,7 +1443,7 @@ }, { "cell_type": "markdown", - "id": "78f5d49a", + "id": "cacf2c51", "metadata": { "editable": true }, @@ -1455,7 +1455,7 @@ }, { "cell_type": "markdown", - "id": "c97d1d7a", + "id": "9b96eea3", "metadata": { "editable": true }, @@ -1465,7 +1465,7 @@ }, { "cell_type": "markdown", - "id": "2df5d3d0", + "id": "cea80d64", "metadata": { "editable": true }, @@ -1477,7 +1477,7 @@ }, { "cell_type": "markdown", - "id": "69153524", + "id": "3ce4ef01", "metadata": { "editable": true }, @@ -1497,7 +1497,7 @@ }, { "cell_type": "markdown", - "id": "b3c67854", + "id": "02fcf3fc", "metadata": { "editable": true }, @@ -1509,7 +1509,7 @@ }, { "cell_type": "markdown", - "id": "c3db6272", + "id": "ea42875a", "metadata": { "editable": true }, @@ -1519,7 +1519,7 @@ }, { "cell_type": "markdown", - "id": "6d2cd34c", + "id": "87f3507a", "metadata": { "editable": true }, @@ -1531,7 +1531,7 @@ }, { "cell_type": "markdown", - "id": "ea43124f", + "id": "d7d840fc", "metadata": { "editable": true }, @@ -1541,7 +1541,7 @@ }, { "cell_type": "markdown", - "id": "58424f50", + "id": "0b29e7e2", "metadata": { "editable": true }, @@ -1552,7 +1552,7 @@ }, { "cell_type": "markdown", - "id": "9252a76b", + "id": "167176f2", "metadata": { "editable": true }, @@ -1564,7 +1564,7 @@ }, { "cell_type": "markdown", - "id": "6869545e", + "id": "c60f64c5", "metadata": { "editable": true }, @@ -1576,7 +1576,7 @@ }, { "cell_type": "markdown", - "id": "00428ab7", + "id": "1b207909", "metadata": { "editable": true }, @@ -1588,7 +1588,7 @@ }, { "cell_type": "markdown", - "id": "a18922d0", + "id": "cfee159c", "metadata": { "editable": true }, @@ -1601,7 +1601,7 @@ }, { "cell_type": "markdown", - "id": "805d1ee0", + "id": "7002d653", "metadata": { "editable": true }, @@ -1612,7 +1612,7 @@ }, { "cell_type": "markdown", - "id": "b57dd5ea", + "id": "e13d8483", "metadata": { "editable": true }, @@ -1624,7 +1624,7 @@ }, { "cell_type": "markdown", - "id": "67976b7d", + "id": "be58b0e1", "metadata": { "editable": true }, @@ -1640,7 +1640,7 @@ }, { "cell_type": "markdown", - "id": "77e0497a", + "id": "46c71245", "metadata": { "editable": true }, @@ -1652,7 +1652,7 @@ }, { "cell_type": "markdown", - "id": "c4586aa6", + "id": "daa7b7da", "metadata": { "editable": true }, @@ -1663,7 +1663,7 @@ }, { "cell_type": "markdown", - "id": "45e92248", + "id": "ab13c237", "metadata": { "editable": true }, @@ -1675,7 +1675,7 @@ }, { "cell_type": "markdown", - "id": "b58df66a", + "id": "b4416925", "metadata": { "editable": true }, @@ -1685,7 +1685,7 @@ }, { "cell_type": "markdown", - "id": "98b1f06e", + "id": "572d4184", "metadata": { "editable": true }, @@ -1697,7 +1697,7 @@ }, { "cell_type": "markdown", - "id": "db4fa5bc", + "id": "3f1c3d2b", "metadata": { "editable": true }, @@ -1707,7 +1707,7 @@ }, { "cell_type": "markdown", - "id": "4c182d76", + "id": "132b319d", "metadata": { "editable": true }, @@ -1719,7 +1719,7 @@ }, { "cell_type": "markdown", - "id": "6f3ac80c", + "id": "24521e78", "metadata": { "editable": true }, @@ -1729,7 +1729,7 @@ }, { "cell_type": "markdown", - "id": "880f9fbe", + "id": "1f98d52a", "metadata": { "editable": true }, @@ -1741,7 +1741,7 @@ }, { "cell_type": "markdown", - "id": "c78b63ba", + "id": "6764a095", "metadata": { "editable": true }, @@ -1765,7 +1765,7 @@ { "cell_type": "code", "execution_count": 6, - "id": "5fa1fd87", + "id": "097ba45d", "metadata": { "collapsed": false, "editable": true @@ -1778,7 +1778,7 @@ }, { "cell_type": "markdown", - "id": "e0b10ac5", + "id": "7e002e40", "metadata": { "editable": true }, @@ -1789,7 +1789,7 @@ }, { "cell_type": "markdown", - "id": "0db173d9", + "id": "8c6eb2d8", "metadata": { "editable": true }, @@ -1801,7 +1801,7 @@ }, { "cell_type": "markdown", - "id": "cac2930c", + "id": "306c4dc4", "metadata": { "editable": true }, @@ -1811,7 +1811,7 @@ }, { "cell_type": "markdown", - "id": "90d618ab", + "id": "15a602aa", "metadata": { "editable": true }, @@ -1823,7 +1823,7 @@ }, { "cell_type": "markdown", - "id": "a0ff7346", + "id": "a0ad20d1", "metadata": { "editable": true }, @@ -1837,7 +1837,7 @@ }, { "cell_type": "markdown", - "id": "337cc827", + "id": "443f2c5f", "metadata": { "editable": true }, @@ -1853,7 +1853,7 @@ }, { "cell_type": "markdown", - "id": "c0b1f537", + "id": "fa5b73b0", "metadata": { "editable": true }, @@ -1863,7 +1863,7 @@ }, { "cell_type": "markdown", - "id": "4c828b26", + "id": "2be1c346", "metadata": { "editable": true }, @@ -1875,7 +1875,7 @@ }, { "cell_type": "markdown", - "id": "2668cc7e", + "id": "0716f795", "metadata": { "editable": true }, @@ -1885,7 +1885,7 @@ }, { "cell_type": "markdown", - "id": "18b9a82d", + "id": "d283d92e", "metadata": { "editable": true }, @@ -1897,7 +1897,7 @@ }, { "cell_type": "markdown", - "id": "f1681651", + "id": "87219710", "metadata": { "editable": true }, @@ -1911,7 +1911,7 @@ }, { "cell_type": "markdown", - "id": "009bc9a7", + "id": "40cb318c", "metadata": { "editable": true }, @@ -1921,7 +1921,7 @@ }, { "cell_type": "markdown", - "id": "a70e82b2", + "id": "51e172a8", "metadata": { "editable": true }, @@ -1932,7 +1932,7 @@ }, { "cell_type": "markdown", - "id": "1fb444bf", + "id": "7a8d39e9", "metadata": { "editable": true }, @@ -1947,7 +1947,7 @@ }, { "cell_type": "markdown", - "id": "efb9792b", + "id": "5794a187", "metadata": { "editable": true }, @@ -1957,7 +1957,7 @@ }, { "cell_type": "markdown", - "id": "7ea2379d", + "id": "0b3a3a65", "metadata": { "editable": true }, @@ -1969,7 +1969,7 @@ }, { "cell_type": "markdown", - "id": "109b0551", + "id": "24aa13fa", "metadata": { "editable": true }, @@ -1981,7 +1981,7 @@ }, { "cell_type": "markdown", - "id": "bbdc55df", + "id": "9ecfc1e6", "metadata": { "editable": true }, @@ -1996,7 +1996,7 @@ }, { "cell_type": "markdown", - "id": "31da0822", + "id": "02725671", "metadata": { "editable": true }, @@ -2009,7 +2009,7 @@ { "cell_type": "code", "execution_count": 7, - "id": "4ddd9983", + "id": "cd0162fa", "metadata": { "collapsed": false, "editable": true @@ -2066,7 +2066,7 @@ }, { "cell_type": "markdown", - "id": "2dfe5753", + "id": "1fad0195", "metadata": { "editable": true }, @@ -2077,7 +2077,7 @@ { "cell_type": "code", "execution_count": 8, - "id": "8e2ca2d9", + "id": "92a78685", "metadata": { "collapsed": false, "editable": true @@ -2104,7 +2104,7 @@ }, { "cell_type": "markdown", - "id": "f9e7b881", + "id": "1401c67e", "metadata": { "editable": true }, @@ -2116,7 +2116,7 @@ }, { "cell_type": "markdown", - "id": "36ba45da", + "id": "ba68372f", "metadata": { "editable": true }, @@ -2128,7 +2128,7 @@ }, { "cell_type": "markdown", - "id": "5e345cc0", + "id": "10caca16", "metadata": { "editable": true }, @@ -2138,7 +2138,7 @@ }, { "cell_type": "markdown", - "id": "14bc3bdb", + "id": "92d72d1b", "metadata": { "editable": true }, @@ -2152,7 +2152,7 @@ }, { "cell_type": "markdown", - "id": "99550715", + "id": "6c020c85", "metadata": { "editable": true }, @@ -2162,7 +2162,7 @@ }, { "cell_type": "markdown", - "id": "631985c4", + "id": "36b002d0", "metadata": { "editable": true }, @@ -2174,7 +2174,7 @@ }, { "cell_type": "markdown", - "id": "98c4126f", + "id": "2d89c0ad", "metadata": { "editable": true }, @@ -2185,7 +2185,7 @@ }, { "cell_type": "markdown", - "id": "c835d44a", + "id": "d85e005a", "metadata": { "editable": true }, @@ -2200,7 +2200,7 @@ }, { "cell_type": "markdown", - "id": "143e72af", + "id": "3e83b611", "metadata": { "editable": true }, @@ -2214,7 +2214,7 @@ }, { "cell_type": "markdown", - "id": "a2acdd56", + "id": "3eaea477", "metadata": { "editable": true }, @@ -2225,7 +2225,7 @@ { "cell_type": "code", "execution_count": 9, - "id": "f025fe90", + "id": "1b451328", "metadata": { "collapsed": false, "editable": true @@ -2286,7 +2286,7 @@ }, { "cell_type": "markdown", - "id": "cca5b63a", + "id": "f7a052a3", "metadata": { "editable": true }, @@ -2308,7 +2308,7 @@ }, { "cell_type": "markdown", - "id": "8b538758", + "id": "a1ae154d", "metadata": { "editable": true }, @@ -2321,7 +2321,7 @@ { "cell_type": "code", "execution_count": 10, - "id": "4cf7d8a8", + "id": "4b5802c8", "metadata": { "collapsed": false, "editable": true @@ -2387,7 +2387,7 @@ }, { "cell_type": "markdown", - "id": "f578d3a4", + "id": "937ec20c", "metadata": { "editable": true }, @@ -2398,7 +2398,7 @@ { "cell_type": "code", "execution_count": 11, - "id": "a70f3a03", + "id": "1c70ef39", "metadata": { "collapsed": false, "editable": true @@ -2472,7 +2472,7 @@ }, { "cell_type": "markdown", - "id": "78be1eda", + "id": "e3f3f35b", "metadata": { "editable": true }, @@ -2484,7 +2484,7 @@ }, { "cell_type": "markdown", - "id": "25a06db8", + "id": "66e49d9f", "metadata": { "editable": true }, @@ -2505,7 +2505,7 @@ }, { "cell_type": "markdown", - "id": "cb111070", + "id": "b001bba9", "metadata": { "editable": true }, @@ -2537,7 +2537,7 @@ }, { "cell_type": "markdown", - "id": "d04f6b36", + "id": "f6fcb791", "metadata": { "editable": true }, @@ -2554,7 +2554,7 @@ }, { "cell_type": "markdown", - "id": "e0671fe5", + "id": "db94a1da", "metadata": { "editable": true }, @@ -2567,7 +2567,7 @@ }, { "cell_type": "markdown", - "id": "3aa36538", + "id": "c4829ebe", "metadata": { "editable": true }, @@ -2580,7 +2580,7 @@ }, { "cell_type": "markdown", - "id": "fa0a5f9c", + "id": "007d0669", "metadata": { "editable": true }, @@ -2593,7 +2593,7 @@ }, { "cell_type": "markdown", - "id": "302c406f", + "id": "45e22e19", "metadata": { "editable": true }, @@ -2607,7 +2607,7 @@ }, { "cell_type": "markdown", - "id": "8af6f0ab", + "id": "603a3d46", "metadata": { "editable": true }, @@ -2629,7 +2629,7 @@ }, { "cell_type": "markdown", - "id": "c4690e57", + "id": "a65a522a", "metadata": { "editable": true }, @@ -2644,7 +2644,7 @@ }, { "cell_type": "markdown", - "id": "4f9e2de7", + "id": "190a4a82", "metadata": { "editable": true }, @@ -2656,7 +2656,7 @@ }, { "cell_type": "markdown", - "id": "327739e1", + "id": "2902d185", "metadata": { "editable": true }, @@ -2669,7 +2669,7 @@ }, { "cell_type": "markdown", - "id": "5545ba16", + "id": "a8a514b5", "metadata": { "editable": true }, @@ -2683,7 +2683,7 @@ }, { "cell_type": "markdown", - "id": "aaaf4854", + "id": "8ee6e9f0", "metadata": { "editable": true }, @@ -2694,7 +2694,7 @@ { "cell_type": "code", "execution_count": 12, - "id": "b51e78c3", + "id": "3a795723", "metadata": { "collapsed": false, "editable": true @@ -2719,7 +2719,7 @@ }, { "cell_type": "markdown", - "id": "1e743992", + "id": "0c179bd5", "metadata": { "editable": true }, @@ -2735,7 +2735,7 @@ }, { "cell_type": "markdown", - "id": "eb787ad1", + "id": "f111b71f", "metadata": { "editable": true }, @@ -2756,7 +2756,7 @@ }, { "cell_type": "markdown", - "id": "4dafd0a4", + "id": "b81892de", "metadata": { "editable": true }, @@ -2776,7 +2776,7 @@ }, { "cell_type": "markdown", - "id": "c528825a", + "id": "f4aaa434", "metadata": { "editable": true }, @@ -2795,7 +2795,7 @@ { "cell_type": "code", "execution_count": 13, - "id": "132e16a2", + "id": "c2713c7c", "metadata": { "collapsed": false, "editable": true @@ -2830,7 +2830,7 @@ }, { "cell_type": "markdown", - "id": "8d03c83d", + "id": "b9ffc236", "metadata": { "editable": true }, @@ -2843,7 +2843,7 @@ { "cell_type": "code", "execution_count": 14, - "id": "4b40b1f2", + "id": "3dd8c731", "metadata": { "collapsed": false, "editable": true @@ -2920,7 +2920,7 @@ }, { "cell_type": "markdown", - "id": "a5fa0d98", + "id": "522a784b", "metadata": { "editable": true }, @@ -2935,7 +2935,7 @@ }, { "cell_type": "markdown", - "id": "c82ed12a", + "id": "fd260edf", "metadata": { "editable": true }, @@ -2950,7 +2950,7 @@ }, { "cell_type": "markdown", - "id": "80a855b6", + "id": "0111d119", "metadata": { "editable": true }, @@ -2962,7 +2962,7 @@ }, { "cell_type": "markdown", - "id": "d0ff292f", + "id": "7786ba69", "metadata": { "editable": true }, @@ -2980,7 +2980,7 @@ }, { "cell_type": "markdown", - "id": "5bbeaa6d", + "id": "a1aa5c70", "metadata": { "editable": true }, @@ -2999,7 +2999,7 @@ }, { "cell_type": "markdown", - "id": "8542f50f", + "id": "7d303a7b", "metadata": { "editable": true }, @@ -3011,7 +3011,7 @@ }, { "cell_type": "markdown", - "id": "a26483ac", + "id": "af7db9f3", "metadata": { "editable": true }, @@ -3021,7 +3021,7 @@ }, { "cell_type": "markdown", - "id": "062ba9d5", + "id": "d853b42d", "metadata": { "editable": true }, @@ -3037,7 +3037,7 @@ }, { "cell_type": "markdown", - "id": "eae6e6e8", + "id": "878642cf", "metadata": { "editable": true }, @@ -3049,7 +3049,7 @@ }, { "cell_type": "markdown", - "id": "dbebbec2", + "id": "a41c7a65", "metadata": { "editable": true }, @@ -3059,7 +3059,7 @@ }, { "cell_type": "markdown", - "id": "210484ea", + "id": "dcc2658e", "metadata": { "editable": true }, @@ -3071,7 +3071,7 @@ }, { "cell_type": "markdown", - "id": "00f879a7", + "id": "02660dc6", "metadata": { "editable": true }, @@ -3081,7 +3081,7 @@ }, { "cell_type": "markdown", - "id": "d2aba931", + "id": "9c309fa8", "metadata": { "editable": true }, @@ -3093,7 +3093,7 @@ }, { "cell_type": "markdown", - "id": "23954b3b", + "id": "ce489766", "metadata": { "editable": true }, @@ -3109,7 +3109,7 @@ }, { "cell_type": "markdown", - "id": "8bee2209", + "id": "ae256ffc", "metadata": { "editable": true }, @@ -3121,7 +3121,7 @@ }, { "cell_type": "markdown", - "id": "12820d4e", + "id": "fe64c5a3", "metadata": { "editable": true }, @@ -3154,7 +3154,7 @@ }, { "cell_type": "markdown", - "id": "a91af524", + "id": "7d736932", "metadata": { "editable": true }, @@ -3166,7 +3166,7 @@ }, { "cell_type": "markdown", - "id": "824c37ae", + "id": "980eb061", "metadata": { "editable": true }, @@ -3184,7 +3184,7 @@ }, { "cell_type": "markdown", - "id": "7eccfb35", + "id": "6aed8662", "metadata": { "editable": true }, @@ -3194,7 +3194,7 @@ }, { "cell_type": "markdown", - "id": "bb5edf8b", + "id": "fca1f3cf", "metadata": { "editable": true }, @@ -3225,7 +3225,7 @@ }, { "cell_type": "markdown", - "id": "42ca26e3", + "id": "63a05ce5", "metadata": { "editable": true }, @@ -3240,7 +3240,7 @@ }, { "cell_type": "markdown", - "id": "5756240b", + "id": "0ce12314", "metadata": { "editable": true }, @@ -3258,7 +3258,7 @@ }, { "cell_type": "markdown", - "id": "c95373ac", + "id": "ffb6f313", "metadata": { "editable": true }, @@ -3270,7 +3270,7 @@ }, { "cell_type": "markdown", - "id": "897c8dd4", + "id": "0d5d3b11", "metadata": { "editable": true }, @@ -3282,7 +3282,7 @@ }, { "cell_type": "markdown", - "id": "e4d0b41c", + "id": "ac44eacb", "metadata": { "editable": true }, @@ -3300,7 +3300,7 @@ }, { "cell_type": "markdown", - "id": "33563225", + "id": "a9b91c67", "metadata": { "editable": true }, @@ -3329,7 +3329,7 @@ }, { "cell_type": "markdown", - "id": "9fef89b1", + "id": "a0535b70", "metadata": { "editable": true }, @@ -3347,7 +3347,7 @@ }, { "cell_type": "markdown", - "id": "e585d71d", + "id": "37fae235", "metadata": { "editable": true }, @@ -3359,7 +3359,7 @@ }, { "cell_type": "markdown", - "id": "7562c9b1", + "id": "24299be0", "metadata": { "editable": true }, @@ -3371,7 +3371,7 @@ }, { "cell_type": "markdown", - "id": "81281189", + "id": "a55ef5dd", "metadata": { "editable": true }, @@ -3383,7 +3383,7 @@ }, { "cell_type": "markdown", - "id": "e5240c76", + "id": "55ebbb4a", "metadata": { "editable": true }, @@ -3395,7 +3395,7 @@ }, { "cell_type": "markdown", - "id": "92f25846", + "id": "6a75cd0f", "metadata": { "editable": true }, @@ -3407,7 +3407,7 @@ }, { "cell_type": "markdown", - "id": "ebd1c2d8", + "id": "bad31ff5", "metadata": { "editable": true }, @@ -3424,7 +3424,7 @@ }, { "cell_type": "markdown", - "id": "d20ee3a5", + "id": "fd7ae8af", "metadata": { "editable": true }, @@ -3443,7 +3443,7 @@ }, { "cell_type": "markdown", - "id": "c331a269", + "id": "ebb9ba37", "metadata": { "editable": true }, @@ -3455,7 +3455,7 @@ }, { "cell_type": "markdown", - "id": "4a71df9e", + "id": "c1a68fa5", "metadata": { "editable": true }, @@ -3469,7 +3469,7 @@ }, { "cell_type": "markdown", - "id": "1a1bb9ae", + "id": "4eaf4055", "metadata": { "editable": true }, @@ -3489,7 +3489,7 @@ }, { "cell_type": "markdown", - "id": "e62b9f26", + "id": "e5ca63c5", "metadata": { "editable": true }, @@ -3527,7 +3527,7 @@ }, { "cell_type": "markdown", - "id": "f9d9adc2", + "id": "2f8a51f3", "metadata": { "editable": true }, @@ -3539,7 +3539,7 @@ }, { "cell_type": "markdown", - "id": "a4d79d56", + "id": "cb951ad3", "metadata": { "editable": true }, @@ -3549,7 +3549,7 @@ }, { "cell_type": "markdown", - "id": "9e5b0a07", + "id": "db24016c", "metadata": { "editable": true }, @@ -3561,7 +3561,7 @@ }, { "cell_type": "markdown", - "id": "fbb6af75", + "id": "1bdf0cb9", "metadata": { "editable": true }, @@ -3572,7 +3572,7 @@ { "cell_type": "code", "execution_count": 15, - "id": "4285b7b4", + "id": "6fb5fe82", "metadata": { "collapsed": false, "editable": true @@ -3617,7 +3617,7 @@ }, { "cell_type": "markdown", - "id": "8455bf36", + "id": "0bcf5cb7", "metadata": { "editable": true }, @@ -3634,7 +3634,7 @@ { "cell_type": "code", "execution_count": 16, - "id": "e1e93736", + "id": "ae500933", "metadata": { "collapsed": false, "editable": true @@ -3662,7 +3662,7 @@ }, { "cell_type": "markdown", - "id": "c51dc7ec", + "id": "f92c5e9e", "metadata": { "editable": true }, @@ -3677,7 +3677,7 @@ { "cell_type": "code", "execution_count": 17, - "id": "d1db6a25", + "id": "dacd393c", "metadata": { "collapsed": false, "editable": true @@ -3721,7 +3721,7 @@ }, { "cell_type": "markdown", - "id": "68b6c330", + "id": "96661f43", "metadata": { "editable": true }, @@ -3731,7 +3731,7 @@ }, { "cell_type": "markdown", - "id": "af9ae977", + "id": "bf5240fb", "metadata": { "editable": true }, @@ -3742,7 +3742,7 @@ { "cell_type": "code", "execution_count": 18, - "id": "9acb4eb4", + "id": "3b1897e7", "metadata": { "collapsed": false, "editable": true @@ -3770,7 +3770,7 @@ }, { "cell_type": "markdown", - "id": "6d6b42f7", + "id": "3912be8c", "metadata": { "editable": true }, @@ -3785,7 +3785,7 @@ }, { "cell_type": "markdown", - "id": "343a76ad", + "id": "4992b4b5", "metadata": { "editable": true }, @@ -3796,7 +3796,7 @@ { "cell_type": "code", "execution_count": 19, - "id": "75535c38", + "id": "e05afdd4", "metadata": { "collapsed": false, "editable": true @@ -3824,7 +3824,7 @@ }, { "cell_type": "markdown", - "id": "d54a7039", + "id": "55bb0b58", "metadata": { "editable": true }, @@ -3835,7 +3835,7 @@ { "cell_type": "code", "execution_count": 20, - "id": "e81e3cef", + "id": "0839da1a", "metadata": { "collapsed": false, "editable": true @@ -3860,7 +3860,7 @@ }, { "cell_type": "markdown", - "id": "f198f442", + "id": "4829f20d", "metadata": { "editable": true }, @@ -3871,7 +3871,7 @@ { "cell_type": "code", "execution_count": 21, - "id": "3fceaab1", + "id": "4fa0bc19", "metadata": { "collapsed": false, "editable": true @@ -3907,7 +3907,7 @@ { "cell_type": "code", "execution_count": 22, - "id": "90a85d63", + "id": "b52bf0c9", "metadata": { "collapsed": false, "editable": true @@ -3927,7 +3927,7 @@ }, { "cell_type": "markdown", - "id": "6962bfc0", + "id": "01cf1786", "metadata": { "editable": true }, @@ -3938,7 +3938,7 @@ { "cell_type": "code", "execution_count": 23, - "id": "23f3bd84", + "id": "746b92c4", "metadata": { "collapsed": false, "editable": true @@ -3976,7 +3976,7 @@ }, { "cell_type": "markdown", - "id": "aba409e2", + "id": "af2b252d", "metadata": { "editable": true }, @@ -3986,7 +3986,7 @@ }, { "cell_type": "markdown", - "id": "ae818693", + "id": "f008f45c", "metadata": { "editable": true }, @@ -4000,7 +4000,7 @@ { "cell_type": "code", "execution_count": 24, - "id": "d743e45d", + "id": "89111774", "metadata": { "collapsed": false, "editable": true @@ -4022,7 +4022,7 @@ }, { "cell_type": "markdown", - "id": "46fb5331", + "id": "89134961", "metadata": { "editable": true }, @@ -4032,7 +4032,7 @@ }, { "cell_type": "markdown", - "id": "5f5ddf2e", + "id": "9ccf91b8", "metadata": { "editable": true }, @@ -4043,7 +4043,7 @@ { "cell_type": "code", "execution_count": 25, - "id": "a10c5598", + "id": "42f2b0b1", "metadata": { "collapsed": false, "editable": true @@ -4065,7 +4065,7 @@ }, { "cell_type": "markdown", - "id": "cea9e306", + "id": "f620e717", "metadata": { "editable": true }, @@ -4078,7 +4078,7 @@ { "cell_type": "code", "execution_count": 26, - "id": "49e2d555", + "id": "42bfe3e0", "metadata": { "collapsed": false, "editable": true @@ -4103,7 +4103,7 @@ }, { "cell_type": "markdown", - "id": "5eb98f5d", + "id": "f2b6bd2b", "metadata": { "editable": true }, @@ -4115,7 +4115,7 @@ { "cell_type": "code", "execution_count": 27, - "id": "f816abb3", + "id": "66ee5069", "metadata": { "collapsed": false, "editable": true @@ -4130,7 +4130,7 @@ }, { "cell_type": "markdown", - "id": "21671b8e", + "id": "f89ccece", "metadata": { "editable": true }, @@ -4145,7 +4145,7 @@ { "cell_type": "code", "execution_count": 28, - "id": "b1a866a7", + "id": "6914ba39", "metadata": { "collapsed": false, "editable": true @@ -4205,7 +4205,7 @@ }, { "cell_type": "markdown", - "id": "2c79ef7d", + "id": "351ca93f", "metadata": { "editable": true }, @@ -4216,7 +4216,7 @@ { "cell_type": "code", "execution_count": 29, - "id": "636cf11f", + "id": "e455eb87", "metadata": { "collapsed": false, "editable": true @@ -4280,7 +4280,7 @@ }, { "cell_type": "markdown", - "id": "90dcdf32", + "id": "ab6b7d5a", "metadata": { "editable": true }, @@ -4291,7 +4291,7 @@ { "cell_type": "code", "execution_count": 30, - "id": "9d954dd3", + "id": "dfe25d60", "metadata": { "collapsed": false, "editable": true @@ -4340,7 +4340,7 @@ }, { "cell_type": "markdown", - "id": "919950b2", + "id": "da215bb2", "metadata": { "editable": true }, @@ -4352,7 +4352,7 @@ { "cell_type": "code", "execution_count": 31, - "id": "a3b4c6f7", + "id": "3a15ed51", "metadata": { "collapsed": false, "editable": true @@ -4436,7 +4436,7 @@ }, { "cell_type": "markdown", - "id": "84f737fa", + "id": "ec160328", "metadata": { "editable": true }, @@ -4447,7 +4447,7 @@ { "cell_type": "code", "execution_count": 32, - "id": "865d644f", + "id": "4465e491", "metadata": { "collapsed": false, "editable": true @@ -4525,7 +4525,7 @@ }, { "cell_type": "markdown", - "id": "1fd6c389", + "id": "65a7e3fd", "metadata": { "editable": true }, @@ -4536,7 +4536,7 @@ { "cell_type": "code", "execution_count": 33, - "id": "18eb26ab", + "id": "fbe692b5", "metadata": { "collapsed": false, "editable": true @@ -4555,9 +4555,9 @@ "def CostOLS(y,X,theta):\n", " return np.sum((y-X @ theta)**2)\n", "\n", - "n = 10000\n", + "n = 1000\n", "x = np.random.rand(n,1)\n", - "y = 2.0+3*x +4*x*x# +np.random.randn(n,1)\n", + "y = 2.0+3*x +4*x*x\n", "\n", "X = np.c_[np.ones((n,1)), x, x*x]\n", "XT_X = X.T @ X\n", @@ -4580,19 +4580,14 @@ "# Including AdaGrad parameter to avoid possible division by zero\n", "delta = 1e-8\n", "for epoch in range(n_epochs):\n", - " # The outer product is calculated from scratch for each epoch\n", - " Giter = np.zeros(shape=(3,3))\n", + " Giter = 0.0\n", " for i in range(m):\n", " random_index = M*np.random.randint(m)\n", " xi = X[random_index:random_index+M]\n", " yi = y[random_index:random_index+M]\n", " gradients = (1.0/M)*training_gradient(yi, xi, theta)\n", - "\t# Calculate the outer product of the gradients\n", - " Giter +=gradients @ gradients.T\n", - "\t# Simpler algorithm with only diagonal elements\n", - " Ginverse = np.c_[eta/(delta+np.sqrt(np.diagonal(Giter)))]\n", - " # compute update\n", - " update = np.multiply(Ginverse,gradients)\n", + " Giter += gradients*gradients\n", + " update = gradients*eta/(delta+np.sqrt(Giter))\n", " theta -= update\n", "print(\"theta from own AdaGrad\")\n", "print(theta)" @@ -4600,7 +4595,7 @@ }, { "cell_type": "markdown", - "id": "119315be", + "id": "f2f38754", "metadata": { "editable": true }, @@ -4610,7 +4605,7 @@ }, { "cell_type": "markdown", - "id": "069b4706", + "id": "d4eba163", "metadata": { "editable": true }, @@ -4621,7 +4616,7 @@ { "cell_type": "code", "execution_count": 34, - "id": "e2b18b40", + "id": "a580c4a5", "metadata": { "collapsed": false, "editable": true @@ -4640,7 +4635,7 @@ "def CostOLS(y,X,theta):\n", " return np.sum((y-X @ theta)**2)\n", "\n", - "n = 10000\n", + "n = 1000\n", "x = np.random.rand(n,1)\n", "y = 2.0+3*x +4*x*x# +np.random.randn(n,1)\n", "\n", @@ -4667,18 +4662,18 @@ "# Including AdaGrad parameter to avoid possible division by zero\n", "delta = 1e-8\n", "for epoch in range(n_epochs):\n", - " Giter = np.zeros(shape=(3,3))\n", + " Giter = 0.0\n", " for i in range(m):\n", " random_index = M*np.random.randint(m)\n", " xi = X[random_index:random_index+M]\n", " yi = y[random_index:random_index+M]\n", " gradients = (1.0/M)*training_gradient(yi, xi, theta)\n", + "\t# Accumulated gradient\n", "\t# Scaling with rho the new and the previous results\n", " Giter = (rho*Giter+(1-rho)*gradients*gradients)\n", "\t# Taking the diagonal only and inverting\n", - " Ginverse = np.c_[eta/(delta+np.sqrt(np.diagonal(Giter)))]\n", + " update = gradients*eta/(delta+np.sqrt(Giter))\n", "\t# Hadamard product\n", - " update = Ginverse*gradients\n", " theta -= update\n", "print(\"theta from own RMSprop\")\n", "print(theta)" @@ -4686,7 +4681,7 @@ }, { "cell_type": "markdown", - "id": "7858afb4", + "id": "0aa9de47", "metadata": { "editable": true }, @@ -4697,7 +4692,7 @@ { "cell_type": "code", "execution_count": 35, - "id": "d416cf5e", + "id": "987e868e", "metadata": { "collapsed": false, "editable": true @@ -4767,7 +4762,7 @@ }, { "cell_type": "markdown", - "id": "fb2a3c56", + "id": "7a1aabcc", "metadata": { "editable": true }, @@ -4778,7 +4773,7 @@ { "cell_type": "code", "execution_count": 36, - "id": "8edbb7b5", + "id": "c44e7a69", "metadata": { "collapsed": false, "editable": true @@ -4822,7 +4817,7 @@ }, { "cell_type": "markdown", - "id": "b081c299", + "id": "0a479a8e", "metadata": { "editable": true }, @@ -4841,7 +4836,7 @@ { "cell_type": "code", "execution_count": 37, - "id": "49314f31", + "id": "e8fdc7be", "metadata": { "collapsed": false, "editable": true diff --git a/doc/src/week39/codes/adagradSGD.py b/doc/src/week39/codes/adagradSGD.py index 4aa6688cd..8070d7380 100644 --- a/doc/src/week39/codes/adagradSGD.py +++ b/doc/src/week39/codes/adagradSGD.py @@ -10,9 +10,9 @@ from autograd import grad def CostOLS(y,X,theta): return np.sum((y-X @ theta)**2) -n = 10000 +n = 1000 x = np.random.rand(n,1) -y = 2.0+3*x +4*x*x# +np.random.randn(n,1) +y = 2.0+3*x +4*x*x X = np.c_[np.ones((n,1)), x, x*x] XT_X = X.T @ X @@ -35,16 +35,15 @@ eta = 0.01 # Including AdaGrad parameter to avoid possible division by zero delta = 1e-8 for epoch in range(n_epochs): - Giter = np.zeros(shape=(3,3)) + Giter = 0.0 for i in range(m): random_index = M*np.random.randint(m) xi = X[random_index:random_index+M] yi = y[random_index:random_index+M] gradients = (1.0/M)*training_gradient(yi, xi, theta) - Giter +=gradients @ gradients.T - Ginverse = np.c_[eta/(delta+np.sqrt(np.diagonal(Giter)))] - update = np.multiply(Ginverse,gradients) - theta -= update + Giter += gradients*gradients + Ginverse = gradients*eta/(delta+np.sqrt(Giter)) + theta -= Ginverse print("theta from own AdaGrad") print(theta) diff --git a/doc/src/week39/codes/rmsprop.py b/doc/src/week39/codes/rmsprop.py index 5239f58b3..d8c5fc384 100644 --- a/doc/src/week39/codes/rmsprop.py +++ b/doc/src/week39/codes/rmsprop.py @@ -10,7 +10,7 @@ from autograd import grad def CostOLS(y,X,theta): return np.sum((y-X @ theta)**2) -n = 10000 +n = 1000 x = np.random.rand(n,1) y = 2.0+3*x +4*x*x# +np.random.randn(n,1) @@ -37,7 +37,7 @@ rho = 0.99 # Including AdaGrad parameter to avoid possible division by zero delta = 1e-8 for epoch in range(n_epochs): - Giter = np.zeros(shape=(3,3)) + Giter = 0.0 for i in range(m): random_index = M*np.random.randint(m) xi = X[random_index:random_index+M] @@ -47,10 +47,8 @@ for epoch in range(n_epochs): # Scaling with rho the new and the previous results Giter = (rho*Giter+(1-rho)*gradients*gradients) # Taking the diagonal only and inverting - Ginverse = np.c_[eta/(delta+np.sqrt(np.diagonal(Giter)))] + update = gradients*eta/(delta+np.sqrt(Giter)) # Hadamard product - update = Ginverse*gradients -# update = np.multiply(Ginverse,gradients) theta -= update print("theta from own RMSprop") print(theta) diff --git a/doc/src/week39/week39.do.txt b/doc/src/week39/week39.do.txt index de109b210..a61d07fa7 100644 --- a/doc/src/week39/week39.do.txt +++ b/doc/src/week39/week39.do.txt @@ -2457,9 +2457,9 @@ from autograd import grad def CostOLS(y,X,theta): return np.sum((y-X @ theta)**2) -n = 10000 +n = 1000 x = np.random.rand(n,1) -y = 2.0+3*x +4*x*x# +np.random.randn(n,1) +y = 2.0+3*x +4*x*x X = np.c_[np.ones((n,1)), x, x*x] XT_X = X.T @ X @@ -2482,22 +2482,19 @@ eta = 0.01 # Including AdaGrad parameter to avoid possible division by zero delta = 1e-8 for epoch in range(n_epochs): - # The outer product is calculated from scratch for each epoch - Giter = np.zeros(shape=(3,3)) + Giter = 0.0 for i in range(m): random_index = M*np.random.randint(m) xi = X[random_index:random_index+M] yi = y[random_index:random_index+M] gradients = (1.0/M)*training_gradient(yi, xi, theta) - # Calculate the outer product of the gradients - Giter +=gradients @ gradients.T - # Simpler algorithm with only diagonal elements - Ginverse = np.c_[eta/(delta+np.sqrt(np.diagonal(Giter)))] - # compute update - update = np.multiply(Ginverse,gradients) + Giter += gradients*gradients + update = gradients*eta/(delta+np.sqrt(Giter)) theta -= update print("theta from own AdaGrad") print(theta) + + !ec Running this code we note an almost perfect agreement with the results from matrix inversion. @@ -2517,7 +2514,7 @@ from autograd import grad def CostOLS(y,X,theta): return np.sum((y-X @ theta)**2) -n = 10000 +n = 1000 x = np.random.rand(n,1) y = 2.0+3*x +4*x*x# +np.random.randn(n,1) @@ -2544,22 +2541,21 @@ rho = 0.99 # Including AdaGrad parameter to avoid possible division by zero delta = 1e-8 for epoch in range(n_epochs): - Giter = np.zeros(shape=(3,3)) + Giter = 0.0 for i in range(m): random_index = M*np.random.randint(m) xi = X[random_index:random_index+M] yi = y[random_index:random_index+M] gradients = (1.0/M)*training_gradient(yi, xi, theta) + # Accumulated gradient # Scaling with rho the new and the previous results Giter = (rho*Giter+(1-rho)*gradients*gradients) # Taking the diagonal only and inverting - Ginverse = np.c_[eta/(delta+np.sqrt(np.diagonal(Giter)))] + update = gradients*eta/(delta+np.sqrt(Giter)) # Hadamard product - update = Ginverse*gradients theta -= update print("theta from own RMSprop") print(theta) - !ec !split