Skip to content

Commit

Permalink
change category
Browse files Browse the repository at this point in the history
  • Loading branch information
patel-zeel committed Aug 31, 2023
1 parent 7327fe2 commit ae14e33
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions posts/2023-08-31-bayesian-gaussian-basis-regression.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"---\n",
"author: Zeel B Patel\n",
"badges: true\n",
"categories: NumPy, Mathematics\n",
"categories: ML\n",
"description: Bayesian Gaussian Basis Regression\n",
"title: Bayesian Gaussian Basis Regression\n",
"date: '2023-08-31'\n",
Expand Down Expand Up @@ -39,7 +39,7 @@
"import matplotlib.pyplot as plt\n",
"\n",
"device = \"cuda\"\n",
"rd.set_backend(\"torch\")\n"
"rd.set_backend(\"torch\")"
]
},
{
Expand Down Expand Up @@ -99,7 +99,7 @@
"y = y.to(device)\n",
"print(x.dtype, y.dtype)\n",
"\n",
"plt.scatter(x.cpu().numpy()[:, 1], y.cpu().numpy())\n"
"plt.scatter(x.cpu().numpy()[:, 1], y.cpu().numpy())"
]
},
{
Expand Down Expand Up @@ -149,7 +149,7 @@
" ],\n",
" dim=1,\n",
" )\n",
" return features\n"
" return features"
]
},
{
Expand All @@ -169,7 +169,7 @@
}
],
"source": [
"GaussianBasis(0.0, 10).to(device)(x).shape"
"GaussianBasis(0.0, 10).to(device)(x).shape\n"
]
},
{
Expand Down Expand Up @@ -228,7 +228,7 @@
" alpha=0.2,\n",
" label=\"95% CI\",\n",
" )\n",
" return ax"
" return ax\n"
]
},
{
Expand All @@ -247,7 +247,7 @@
" log_var_noise = nn.Parameter(torch.tensor(0.1)).to(device)\n",
" log_var_noise.requires_grad = True\n",
" m0.requires_grad = False\n",
" s0.requires_grad = True\n"
" s0.requires_grad = True"
]
},
{
Expand Down Expand Up @@ -295,7 +295,7 @@
" losses.append(loss.item())\n",
" pbar.set_description(f\"loss: {loss.item():.4f}\")\n",
"\n",
"plt.plot(losses)"
"plt.plot(losses)\n"
]
},
{
Expand Down Expand Up @@ -323,7 +323,7 @@
"with torch.no_grad():\n",
" ax.scatter(x.cpu().numpy()[:, 1], y.cpu().numpy())\n",
" # ax.vlines(mlp.transform.grid.cpu().numpy(), -1, 1, color=\"black\", alpha=0.2)\n",
"plt.show()\n"
"plt.show()"
]
},
{
Expand All @@ -344,7 +344,7 @@
}
],
"source": [
"torch.exp(log_var_noise), s0\n"
"torch.exp(log_var_noise), s0"
]
},
{
Expand All @@ -370,7 +370,7 @@
" log_var_noise = nn.Parameter(torch.tensor(0.1)).to(device)\n",
" log_var_noise.requires_grad = True\n",
" m0.requires_grad = False\n",
" s0.requires_grad = True\n"
" s0.requires_grad = True"
]
},
{
Expand Down Expand Up @@ -418,7 +418,7 @@
" losses.append(loss.item())\n",
" pbar.set_description(f\"loss: {loss.item():.4f}\")\n",
"\n",
"plt.plot(losses)"
"plt.plot(losses)\n"
]
},
{
Expand Down Expand Up @@ -446,7 +446,7 @@
"with torch.no_grad():\n",
" ax.scatter(x.cpu().numpy()[:, 1], y.cpu().numpy())\n",
" ax.vlines(mlp.transform.grid.cpu().numpy(), -1, 1, color=\"black\", alpha=0.2)\n",
"plt.show()\n"
"plt.show()"
]
},
{
Expand All @@ -472,7 +472,7 @@
" log_var_noise = nn.Parameter(torch.tensor(0.1)).to(device)\n",
" log_var_noise.requires_grad = True\n",
" m0.requires_grad = False\n",
" s0.requires_grad = True\n"
" s0.requires_grad = True"
]
},
{
Expand Down Expand Up @@ -520,7 +520,7 @@
" losses.append(loss.item())\n",
" pbar.set_description(f\"loss: {loss.item():.4f}\")\n",
"\n",
"plt.plot(losses)"
"plt.plot(losses)\n"
]
},
{
Expand Down Expand Up @@ -548,7 +548,7 @@
"with torch.no_grad():\n",
" ax.scatter(x.cpu().numpy()[:, 1], y.cpu().numpy())\n",
" ax.vlines(mlp.grid.cpu().numpy(), -1, 1, color=\"black\", alpha=0.2)\n",
"plt.show()\n"
"plt.show()"
]
}
],
Expand Down

0 comments on commit ae14e33

Please sign in to comment.