From c1b0b5fdc0e5ddb9101135a20dbf79773973bdd9 Mon Sep 17 00:00:00 2001 From: Morten Hjorth-Jensen Date: Thu, 7 Oct 2021 09:02:53 +0200 Subject: [PATCH] update --- doc/pub/week40/html/._week40-bs012.html | 6 +++--- doc/pub/week40/html/week40-reveal.html | 6 +++--- doc/pub/week40/html/week40-solarized.html | 6 +++--- doc/pub/week40/html/week40.html | 6 +++--- doc/pub/week40/ipynb/ipynb-week40-src.tar.gz | Bin 33808 -> 33808 bytes doc/pub/week40/ipynb/week40.ipynb | 6 +++--- doc/src/week40/week40.do.txt | 6 +++--- 7 files changed, 18 insertions(+), 18 deletions(-) diff --git a/doc/pub/week40/html/._week40-bs012.html b/doc/pub/week40/html/._week40-bs012.html index efcfdd25b..59ac9c0b4 100644 --- a/doc/pub/week40/html/._week40-bs012.html +++ b/doc/pub/week40/html/._week40-bs012.html @@ -319,11 +319,11 @@ MathJax.Hub.Config({ import matplotlib.pyplot as plt from sklearn.linear_model import SGDRegressor -n = 100 +n = 1000 x = 2*np.random.rand(n,1) y = 4+3*x+np.random.randn(n,1) -X = np.c_[np.ones((m,1)), x] +X = np.c_[np.ones((n,1)), x] theta_linreg = np.linalg.inv(X.T @ X) @ (X.T @ y) print("Own inversion") print(theta_linreg) @@ -364,7 +364,7 @@ theta = np.= np.random.randint(m) xi = X[random_index:random_index+1] yi = y[random_index:random_index+1] - gradients = (2.0/m) * xi.T @ ((xi @ theta)-yi) + gradients = 2.0* xi.T @ ((xi @ theta)-yi) eta = learning_schedule(epoch*m+i) theta = theta - eta*gradients print("theta from own sdg") diff --git a/doc/pub/week40/html/week40-reveal.html b/doc/pub/week40/html/week40-reveal.html index 0cee2bee7..b271cd4fd 100644 --- a/doc/pub/week40/html/week40-reveal.html +++ b/doc/pub/week40/html/week40-reveal.html @@ -436,11 +436,11 @@ We note that we have defined several hyperparameters. These are now the number o import matplotlib.pyplot as plt from sklearn.linear_model import SGDRegressor -n = 100 +n = 1000 x = 2*np.random.rand(n,1) y = 4+3*x+np.random.randn(n,1) -X = np.c_[np.ones((m,1)), x] +X = np.c_[np.ones((n,1)), x] theta_linreg = np.linalg.inv(X.T @ X) @ (X.T @ y) print("Own inversion") print(theta_linreg) @@ -481,7 +481,7 @@ theta = np.random.randn(2,1] yi = y[random_index:random_index+1] - gradients = (2.0/m) * xi.T @ ((xi @ theta)-yi) + gradients = 2.0* xi.T @ ((xi @ theta)-yi) eta = learning_schedule(epoch*m+i) theta = theta - eta*gradients print("theta from own sdg") diff --git a/doc/pub/week40/html/week40-solarized.html b/doc/pub/week40/html/week40-solarized.html index 2ad884dd5..917133f75 100644 --- a/doc/pub/week40/html/week40-solarized.html +++ b/doc/pub/week40/html/week40-solarized.html @@ -525,11 +525,11 @@ We note that we have defined several hyperparameters. These are now the number o import matplotlib.pyplot as plt from sklearn.linear_model import SGDRegressor -n = 100 +n = 1000 x = 2*np.random.rand(n,1) y = 4+3*x+np.random.randn(n,1) -X = np.c_[np.ones((m,1)), x] +X = np.c_[np.ones((n,1)), x] theta_linreg = np.linalg.inv(X.T @ X) @ (X.T @ y) print("Own inversion") print(theta_linreg) @@ -570,7 +570,7 @@ theta = np.random.randn(2,1] yi = y[random_index:random_index+1] - gradients = (2.0/m) * xi.T @ ((xi @ theta)-yi) + gradients = 2.0* xi.T @ ((xi @ theta)-yi) eta = learning_schedule(epoch*m+i) theta = theta - eta*gradients print("theta from own sdg") diff --git a/doc/pub/week40/html/week40.html b/doc/pub/week40/html/week40.html index 0bb83f2fb..e9ed59b8a 100644 --- a/doc/pub/week40/html/week40.html +++ b/doc/pub/week40/html/week40.html @@ -530,11 +530,11 @@ We note that we have defined several hyperparameters. These are now the number o import matplotlib.pyplot as plt from sklearn.linear_model import SGDRegressor -n = 100 +n = 1000 x = 2*np.random.rand(n,1) y = 4+3*x+np.random.randn(n,1) -X = np.c_[np.ones((m,1)), x] +X = np.c_[np.ones((n,1)), x] theta_linreg = np.linalg.inv(X.T @ X) @ (X.T @ y) print("Own inversion") print(theta_linreg) @@ -575,7 +575,7 @@ theta = np.= np.random.randint(m) xi = X[random_index:random_index+1] yi = y[random_index:random_index+1] - gradients = (2.0/m) * xi.T @ ((xi @ theta)-yi) + gradients = 2.0* xi.T @ ((xi @ theta)-yi) eta = learning_schedule(epoch*m+i) theta = theta - eta*gradients print("theta from own sdg") diff --git a/doc/pub/week40/ipynb/ipynb-week40-src.tar.gz b/doc/pub/week40/ipynb/ipynb-week40-src.tar.gz index e1c7ba345deac7249463b2f930ae9fdf07f60066..912b3cb084dc8283cb00584a64ec05cbc68b1866 100644 GIT binary patch delta 17 YcmbQx!8D1Qjci;k05kgq!~g&Q diff --git a/doc/pub/week40/ipynb/week40.ipynb b/doc/pub/week40/ipynb/week40.ipynb index 4e1233143..60cfea892 100644 --- a/doc/pub/week40/ipynb/week40.ipynb +++ b/doc/pub/week40/ipynb/week40.ipynb @@ -311,11 +311,11 @@ "import matplotlib.pyplot as plt\n", "from sklearn.linear_model import SGDRegressor\n", "\n", - "n = 100\n", + "n = 1000\n", "x = 2*np.random.rand(n,1)\n", "y = 4+3*x+np.random.randn(n,1)\n", "\n", - "X = np.c_[np.ones((m,1)), x]\n", + "X = np.c_[np.ones((n,1)), x]\n", "theta_linreg = np.linalg.inv(X.T @ X) @ (X.T @ y)\n", "print(\"Own inversion\")\n", "print(theta_linreg)\n", @@ -356,7 +356,7 @@ " random_index = np.random.randint(m)\n", " xi = X[random_index:random_index+1]\n", " yi = y[random_index:random_index+1]\n", - " gradients = (2.0/m) * xi.T @ ((xi @ theta)-yi)\n", + " gradients = 2.0* xi.T @ ((xi @ theta)-yi)\n", " eta = learning_schedule(epoch*m+i)\n", " theta = theta - eta*gradients\n", "print(\"theta from own sdg\")\n", diff --git a/doc/src/week40/week40.do.txt b/doc/src/week40/week40.do.txt index cc16ff576..bbdf5f9af 100644 --- a/doc/src/week40/week40.do.txt +++ b/doc/src/week40/week40.do.txt @@ -236,11 +236,11 @@ import numpy as np import matplotlib.pyplot as plt from sklearn.linear_model import SGDRegressor -n = 100 +n = 1000 x = 2*np.random.rand(n,1) y = 4+3*x+np.random.randn(n,1) -X = np.c_[np.ones((m,1)), x] +X = np.c_[np.ones((n,1)), x] theta_linreg = np.linalg.inv(X.T @ X) @ (X.T @ y) print("Own inversion") print(theta_linreg) @@ -281,7 +281,7 @@ for epoch in range(n_epochs): random_index = np.random.randint(m) xi = X[random_index:random_index+1] yi = y[random_index:random_index+1] - gradients = (2.0/m) * xi.T @ ((xi @ theta)-yi) + gradients = 2.0* xi.T @ ((xi @ theta)-yi) eta = learning_schedule(epoch*m+i) theta = theta - eta*gradients print("theta from own sdg")