Created using Colab

This commit is contained in:
udlbook
2025-11-05 09:48:13 -05:00
parent 16b72a8a9e
commit 4a08818706

View File

@@ -301,7 +301,7 @@
"source": [
"def loss_function_1D(dist_prop, data, model, phi_start, search_direction):\n",
" # Return the loss after moving this far\n",
" return compute_loss(data[0,:], data[1,:], model, phi_start+ search_direction * dist_prop)\n",
" return compute_loss(data[0,:], data[1,:], model, phi_start - search_direction * dist_prop)\n",
"\n",
"def line_search(data, model, phi, gradient, thresh=.00001, max_dist = 0.1, max_iter = 15, verbose=False):\n",
" # Initialize four points along the range we are going to search\n",
@@ -365,7 +365,7 @@
"def gradient_descent_step(phi, data, model):\n",
" # TODO -- update Phi with the gradient descent step (equation 6.3)\n",
" # 1. Compute the gradient (you wrote this function above)\n",
" # 2. Find the best step size alpha using line search function (above) -- use negative gradient as going downhill\n",
" # 2. Find the best step size alpha using line search function (above)\n",
" # 3. Update the parameters phi based on the gradient and the step size alpha.\n",
"\n",
" return phi"