Created using Colab
This commit is contained in:
@@ -301,7 +301,7 @@
|
|||||||
"source": [
|
"source": [
|
||||||
"def loss_function_1D(dist_prop, data, model, phi_start, search_direction):\n",
|
"def loss_function_1D(dist_prop, data, model, phi_start, search_direction):\n",
|
||||||
" # Return the loss after moving this far\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",
|
"\n",
|
||||||
"def line_search(data, model, phi, gradient, thresh=.00001, max_dist = 0.1, max_iter = 15, verbose=False):\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",
|
" # Initialize four points along the range we are going to search\n",
|
||||||
@@ -365,7 +365,7 @@
|
|||||||
"def gradient_descent_step(phi, data, model):\n",
|
"def gradient_descent_step(phi, data, model):\n",
|
||||||
" # TODO -- update Phi with the gradient descent step (equation 6.3)\n",
|
" # TODO -- update Phi with the gradient descent step (equation 6.3)\n",
|
||||||
" # 1. Compute the gradient (you wrote this function above)\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",
|
" # 3. Update the parameters phi based on the gradient and the step size alpha.\n",
|
||||||
"\n",
|
"\n",
|
||||||
" return phi"
|
" return phi"
|
||||||
|
|||||||
Reference in New Issue
Block a user