Fix issues typos in 6_3_Stochastic_Gradient_Descent.ipynb

This commit is contained in:
Youcef Rahal
2024-02-06 20:48:25 -05:00
parent 8e3008673d
commit 732fc6f0b7
2 changed files with 7 additions and 7 deletions

View File

@@ -317,7 +317,7 @@
" b = 0.33 * max_dist\n", " b = 0.33 * max_dist\n",
" c = 0.66 * max_dist\n", " c = 0.66 * max_dist\n",
" d = 1.0 * max_dist\n", " d = 1.0 * max_dist\n",
" n_iter =0;\n", " n_iter = 0\n",
"\n", "\n",
" # While we haven't found the minimum closely enough\n", " # While we haven't found the minimum closely enough\n",
" while np.abs(b-c) > thresh and n_iter < max_iter:\n", " while np.abs(b-c) > thresh and n_iter < max_iter:\n",

View File

@@ -53,7 +53,7 @@
}, },
"outputs": [], "outputs": [],
"source": [ "source": [
"# Let's create our training data 30 pairs {x_i, y_i}\n", "# Let's create our training data of 30 pairs {x_i, y_i}\n",
"# We'll try to fit the Gabor model to these data\n", "# We'll try to fit the Gabor model to these data\n",
"data = np.array([[-1.920e+00,-1.422e+01,1.490e+00,-1.940e+00,-2.389e+00,-5.090e+00,\n", "data = np.array([[-1.920e+00,-1.422e+01,1.490e+00,-1.940e+00,-2.389e+00,-5.090e+00,\n",
" -8.861e+00,3.578e+00,-6.010e+00,-6.995e+00,3.634e+00,8.743e-01,\n", " -8.861e+00,3.578e+00,-6.010e+00,-6.995e+00,3.634e+00,8.743e-01,\n",
@@ -128,7 +128,7 @@
"id": "QU5mdGvpTtEG" "id": "QU5mdGvpTtEG"
}, },
"source": [ "source": [
"Now lets create compute the sum of squares loss for the training data" "Now let's compute the sum of squares loss for the training data"
] ]
}, },
{ {
@@ -198,7 +198,7 @@
" b = np.floor(my_colormap_vals_dec - r * 256 *256 - g * 256)\n", " b = np.floor(my_colormap_vals_dec - r * 256 *256 - g * 256)\n",
" my_colormap = ListedColormap(np.vstack((r,g,b)).transpose()/255.0)\n", " my_colormap = ListedColormap(np.vstack((r,g,b)).transpose()/255.0)\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",
@@ -343,7 +343,7 @@
" b = 0.33 * max_dist\n", " b = 0.33 * max_dist\n",
" c = 0.66 * max_dist\n", " c = 0.66 * max_dist\n",
" d = 1.0 * max_dist\n", " d = 1.0 * max_dist\n",
" n_iter =0;\n", " n_iter = 0\n",
"\n", "\n",
" # While we haven't found the minimum closely enough\n", " # While we haven't found the minimum closely enough\n",
" while np.abs(b-c) > thresh and n_iter < max_iter:\n", " while np.abs(b-c) > thresh and n_iter < max_iter:\n",
@@ -367,7 +367,7 @@
" 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",
" # then point d becomes point c, and\n", " # point d becomes point c, and\n",
" # point b becomes 1/3 between a and new d\n", " # point b becomes 1/3 between a and new d\n",
" # point c becomes 2/3 between a and new d\n", " # point c becomes 2/3 between a and new d\n",
" if lossb < lossc:\n", " if lossb < lossc:\n",
@@ -377,7 +377,7 @@
" continue\n", " continue\n",
"\n", "\n",
" # Rule #2 If point c is less than point b then\n", " # Rule #2 If point c is less than point b then\n",
" # then point a becomes point b, and\n", " # point a becomes point b, and\n",
" # point b becomes 1/3 between new a and d\n", " # point b becomes 1/3 between new a and d\n",
" # point c becomes 2/3 between new a and d\n", " # point c becomes 2/3 between new a and d\n",
" a = b\n", " a = b\n",