Skip to content

Commit

Permalink
Created using Colaboratory
Browse files Browse the repository at this point in the history
  • Loading branch information
udlbook committed Sep 29, 2023
1 parent 4a08fa4 commit 8c658ac
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Notebooks/Chap07/7_1_Backpropagation_in_Toy_Model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"metadata": {
"colab": {
"provenance": [],
"authorship_tag": "ABX9TyOwOpROPBel8eYGzp5DGRkt",
"authorship_tag": "ABX9TyP5wHK5E7/el+vxU947K3q8",
"include_colab_link": true
},
"kernelspec": {
Expand Down Expand Up @@ -55,7 +55,7 @@
"This is a composition of the functions $\\cos[\\bullet],\\exp[\\bullet],\\sin[\\bullet]$. I chose these just because you probably already know the derivatives of these functions:\n",
"\n",
"\\begin{eqnarray*}\n",
" \\frac{\\partial \\cos[z]}{\\partial z} = -\\sin[z] \\quad\\quad \\frac{\\partial \\exp[z]}{\\partial z} = \\exp[z] \\quad\\quad \\frac{\\partial \\sin[z]}{\\partial z} = -\\cos[z].\n",
" \\frac{\\partial \\cos[z]}{\\partial z} = -\\sin[z] \\quad\\quad \\frac{\\partial \\exp[z]}{\\partial z} = \\exp[z] \\quad\\quad \\frac{\\partial \\sin[z]}{\\partial z} = \\cos[z].\n",
"\\end{eqnarray*}\n",
"\n",
"Suppose that we have a least squares loss function:\n",
Expand Down Expand Up @@ -107,8 +107,8 @@
" return beta3+omega3 * np.cos(beta2 + omega2 * np.exp(beta1 + omega1 * np.sin(beta0 + omega0 * x)))\n",
"\n",
"def likelihood(x, y, beta0, beta1, beta2, beta3, omega0, omega1, omega2, omega3):\n",
" diff = fn(x, beta0, beta1, beta2, beta3, omega0, omega1, omega2, omega3) - y ;\n",
" return diff * diff ;"
" diff = fn(x, beta0, beta1, beta2, beta3, omega0, omega1, omega2, omega3) - y\n",
" return diff * diff"
]
},
{
Expand All @@ -123,8 +123,8 @@
{
"cell_type": "code",
"source": [
"beta0 = 1.0; beta1 = 2.0; beta2 = -3.0; beta3 = 0.4;\n",
"omega0 = 0.1; omega1 = -0.4; omega2 = 2.0; omega3 = 3.0;\n",
"beta0 = 1.0; beta1 = 2.0; beta2 = -3.0; beta3 = 0.4\n",
"omega0 = 0.1; omega1 = -0.4; omega2 = 2.0; omega3 = 3.0\n",
"x = 2.3; y =2.0\n",
"l_i_func = likelihood(x,y,beta0,beta1,beta2,beta3,omega0,omega1,omega2,omega3)\n",
"print('l_i=%3.3f'%l_i_func)"
Expand Down

0 comments on commit 8c658ac

Please sign in to comment.