Merge pull request #188 from yrahal/main

Fix more Chap09 tiny typos
This commit is contained in:
udlbook
2024-05-16 16:01:49 -04:00
committed by GitHub
3 changed files with 15 additions and 15 deletions

View File

@@ -52,7 +52,7 @@
"# import libraries\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"# Define seed so get same results each time\n",
"# Define seed to get same results each time\n",
"np.random.seed(1)"
]
},
@@ -80,7 +80,7 @@
" for i in range(n_data):\n",
" x[i] = np.random.uniform(i/n_data, (i+1)/n_data, 1)\n",
"\n",
" # y value from running through functoin and adding noise\n",
" # y value from running through function and adding noise\n",
" y = np.ones(n_data)\n",
" for i in range(n_data):\n",
" y[i] = true_function(x[i])\n",
@@ -96,7 +96,7 @@
{
"cell_type": "code",
"source": [
"# Draw the fitted function, together win uncertainty used to generate points\n",
"# Draw the fitted function, together with uncertainty used to generate points\n",
"def plot_function(x_func, y_func, x_data=None,y_data=None, x_model = None, y_model =None, sigma_func = None, sigma_model=None):\n",
"\n",
" fig,ax = plt.subplots()\n",
@@ -137,7 +137,7 @@
"n_data = 15\n",
"x_data,y_data = generate_data(n_data, sigma_func)\n",
"\n",
"# Plot the functinon, data and uncertainty\n",
"# Plot the function, data and uncertainty\n",
"plot_function(x_func, y_func, x_data, y_data, sigma_func=sigma_func)"
],
"metadata": {
@@ -216,7 +216,7 @@
"# Closed form solution\n",
"beta, omega = fit_model_closed_form(x_data,y_data,n_hidden=14)\n",
"\n",
"# Get prediction for model across graph grange\n",
"# Get prediction for model across graph range\n",
"x_model = np.linspace(0,1,100);\n",
"y_model = network(x_model, beta, omega)\n",
"\n",
@@ -297,7 +297,7 @@
{
"cell_type": "code",
"source": [
"# Plot the median of the results\n",
"# Plot the mean of the results\n",
"# TODO -- find the mean prediction\n",
"# Replace this line\n",
"y_model_mean = all_y_model[0,:]\n",

View File

@@ -36,7 +36,7 @@
"# import libraries\n",
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"# Define seed so get same results each time\n",
"# Define seed to get same results each time\n",
"np.random.seed(1)"
]
},
@@ -85,7 +85,7 @@
},
"outputs": [],
"source": [
"# Draw the fitted function, together win uncertainty used to generate points\n",
"# Draw the fitted function, together with uncertainty used to generate points\n",
"def plot_function(x_func, y_func, x_data=None,y_data=None, x_model = None, y_model =None, sigma_func = None, sigma_model=None):\n",
"\n",
" fig,ax = plt.subplots()\n",
@@ -220,7 +220,7 @@
" &\\propto&\\text{Norm}_{\\boldsymbol\\phi}\\biggl[\\frac{1}{\\sigma^2}\\left(\\frac{1}{\\sigma^2}\\mathbf{H}\\mathbf{H}^T+\\frac{1}{\\sigma_p^2}\\mathbf{I}\\right)^{-1}\\mathbf{H}\\mathbf{y},\\left(\\frac{1}{\\sigma^2}\\mathbf{H}\\mathbf{H}^T+\\frac{1}{\\sigma_p^2}\\mathbf{I}\\right)^{-1}\\biggr].\n",
"\\end{align}\n",
"\n",
"In fact, since this already a normal distribution, the constant of proportionality must be one and we can write\n",
"In fact, since this is already a normal distribution, the constant of proportionality must be one and we can write\n",
"\n",
"\\begin{align}\n",
" Pr(\\boldsymbol\\phi|\\{\\mathbf{x}_{i},\\mathbf{y}_{i}\\}) &=& \\text{Norm}_{\\boldsymbol\\phi}\\biggl[\\frac{1}{\\sigma^2}\\left(\\frac{1}{\\sigma^2}\\mathbf{H}\\mathbf{H}^T+\\frac{1}{\\sigma_p^2}\\mathbf{I}\\right)^{-1}\\mathbf{H}\\mathbf{y},\\left(\\frac{1}{\\sigma^2}\\mathbf{H}\\mathbf{H}^T+\\frac{1}{\\sigma_p^2}\\mathbf{I}\\right)^{-1}\\biggr].\n",

View File

@@ -95,7 +95,7 @@
"D_k = 200 # Hidden dimensions\n",
"D_o = 10 # Output dimensions\n",
"\n",
"# Define a model with two hidden layers of size 100\n",
"# Define a model with two hidden layers of size 200\n",
"# And ReLU activations between them\n",
"model = nn.Sequential(\n",
"nn.Linear(D_i, D_k),\n",