Created using Colaboratory

This commit is contained in:
udlbook
2023-12-20 14:38:30 -05:00
parent 3b266ba33b
commit 7e264f5310

View File

@@ -4,7 +4,6 @@
"metadata": { "metadata": {
"colab": { "colab": {
"provenance": [], "provenance": [],
"authorship_tag": "ABX9TyN2N4cCnlIobOZXEjcwAvZ5",
"include_colab_link": true "include_colab_link": true
}, },
"kernelspec": { "kernelspec": {
@@ -310,9 +309,9 @@
{ {
"cell_type": "code", "cell_type": "code",
"source": [ "source": [
"def loss_function_1D(dist_prop, data, model, phi_start, gradient):\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+ gradient * 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",