diff --git a/Notebooks/Chap09/9_1_L2_Regularization.ipynb b/Notebooks/Chap09/9_1_L2_Regularization.ipynb index 4830640..dd3481f 100644 --- a/Notebooks/Chap09/9_1_L2_Regularization.ipynb +++ b/Notebooks/Chap09/9_1_L2_Regularization.ipynb @@ -178,7 +178,7 @@ "\n", "def draw_loss_function(compute_loss, data, model, my_colormap, phi_iters = None):\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", " loss_mesh = np.zeros_like(freqs_mesh)\n", " # Compute loss for every set of parameters\n", @@ -304,7 +304,7 @@ "for c_step in range (n_steps):\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", - " # Measure loss and draw model every 4th step\n", + " # Measure loss and draw model every 8th step\n", " if c_step % 8 == 0:\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", @@ -369,7 +369,7 @@ "# Code to draw the regularization function\n", "def draw_reg_function():\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", " loss_mesh = np.zeros_like(freqs_mesh)\n", " # Compute loss for every set of parameters\n", @@ -399,7 +399,7 @@ "# Code to draw loss function with regularization\n", "def draw_loss_function_reg(data, model, lambda_, my_colormap, phi_iters = None):\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", " loss_mesh = np.zeros_like(freqs_mesh)\n", " # Compute loss for every set of parameters\n", @@ -512,7 +512,7 @@ "for c_step in range (n_steps):\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", - " # Measure loss and draw model every 4th step\n", + " # Measure loss and draw model every 8th step\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", " 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", "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": { "id": "wrszSLrqZG4k"