From 1343b68c607480d412cdcb14b66e5e12b946e0f6 Mon Sep 17 00:00:00 2001 From: Youcef Rahal Date: Thu, 9 May 2024 17:51:53 -0400 Subject: [PATCH 1/3] Fix more Chap09 tiny typos --- Notebooks/Chap09/9_3_Ensembling.ipynb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Notebooks/Chap09/9_3_Ensembling.ipynb b/Notebooks/Chap09/9_3_Ensembling.ipynb index 3335c06..be9b343 100644 --- a/Notebooks/Chap09/9_3_Ensembling.ipynb +++ b/Notebooks/Chap09/9_3_Ensembling.ipynb @@ -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", @@ -325,4 +325,4 @@ } } ] -} \ No newline at end of file +} From 2ac42e70d3f0083c4e825c65fa4af527d64fad7a Mon Sep 17 00:00:00 2001 From: Youcef Rahal Date: Sat, 11 May 2024 15:20:11 -0400 Subject: [PATCH 2/3] Fix more Chap09 tiny typos --- Notebooks/Chap09/9_4_Bayesian_Approach.ipynb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Notebooks/Chap09/9_4_Bayesian_Approach.ipynb b/Notebooks/Chap09/9_4_Bayesian_Approach.ipynb index b5d77f9..ef7c3b8 100644 --- a/Notebooks/Chap09/9_4_Bayesian_Approach.ipynb +++ b/Notebooks/Chap09/9_4_Bayesian_Approach.ipynb @@ -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", @@ -423,4 +423,4 @@ }, "nbformat": 4, "nbformat_minor": 0 -} \ No newline at end of file +} From 0233131b0755a9aa48641baf9fdf0515d26e83e9 Mon Sep 17 00:00:00 2001 From: Youcef Rahal Date: Sun, 12 May 2024 15:27:57 -0400 Subject: [PATCH 3/3] Notebook 9.5 --- Notebooks/Chap09/9_5_Augmentation.ipynb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Notebooks/Chap09/9_5_Augmentation.ipynb b/Notebooks/Chap09/9_5_Augmentation.ipynb index 99a98c7..adc8e57 100644 --- a/Notebooks/Chap09/9_5_Augmentation.ipynb +++ b/Notebooks/Chap09/9_5_Augmentation.ipynb @@ -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", @@ -186,7 +186,7 @@ "ax.plot(errors_test,'b-',label='test')\n", "ax.set_ylim(0,100); ax.set_xlim(0,n_epoch)\n", "ax.set_xlabel('Epoch'); ax.set_ylabel('Error')\n", - "ax.set_title('TrainError %3.2f, Test Error %3.2f'%(errors_train[-1],errors_test[-1]))\n", + "ax.set_title('Train Error %3.2f, Test Error %3.2f'%(errors_train[-1],errors_test[-1]))\n", "ax.legend()\n", "plt.show()" ], @@ -233,7 +233,7 @@ "cell_type": "code", "source": [ "n_data_orig = data['x'].shape[0]\n", - "# We'll double the amount o fdata\n", + "# We'll double the amount of data\n", "n_data_augment = n_data_orig+4000\n", "augmented_x = np.zeros((n_data_augment, D_i))\n", "augmented_y = np.zeros(n_data_augment)\n", @@ -343,4 +343,4 @@ } } ] -} \ No newline at end of file +}