Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
141 changes: 108 additions & 33 deletions deblurring/staircase.ipynb

Large diffs are not rendered by default.

189 changes: 116 additions & 73 deletions inpainting/inpainting_DnCNN.ipynb

Large diffs are not rendered by default.

100 changes: 82 additions & 18 deletions inpainting/inpainting_wavelet.ipynb

Large diffs are not rendered by default.

109 changes: 100 additions & 9 deletions pde_boundary_value/boundary_value_2d.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"import dolfin as df\n",
"from cuqi.distribution import Gaussian, JointDistribution\n",
"from cuqi.implicitprior import RegularizedGMRF\n",
"from cuqi.experimental.mcmc import RegularizedLinearRTO, LinearRTO"
"from cuqi.sampler import RegularizedLinearRTO, LinearRTO"
]
},
{
Expand All @@ -32,7 +32,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"CUQI version: 1.3.0\n"
"CUQI version: 1.5.0\n"
]
}
],
Expand Down Expand Up @@ -92,7 +92,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 6,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -171,7 +171,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"Sample: 100%|██████████| 1000/1000 [02:24<00:00, 6.91it/s, acc rate: 100.00%]\n"
"Sample: 100%|██████████| 1000/1000 [02:15<00:00, 7.37it/s, acc rate: 100.00%]\n"
]
}
],
Expand All @@ -192,7 +192,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 10,
"metadata": {},
"outputs": [
{
Expand All @@ -217,7 +217,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 11,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -269,7 +269,7 @@
"name": "stderr",
"output_type": "stream",
"text": [
"Sample: 100%|██████████| 1000/1000 [05:31<00:00, 3.02it/s, acc rate: 100.00%]\n"
"Sample: 100%|██████████| 1000/1000 [05:26<00:00, 3.06it/s, acc rate: 100.00%]\n"
]
}
],
Expand Down Expand Up @@ -299,7 +299,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 15,
"metadata": {},
"outputs": [
{
Expand All @@ -323,7 +323,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 16,
"metadata": {},
"outputs": [
{
Expand All @@ -348,6 +348,97 @@
"plt.xlim([0, 1])\n",
"plt.savefig(\"bv_gmrf_tv_samples.pdf\", bbox_inches='tight')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Difference"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"GMRF-TV error: 0.012895373480413808\n",
"GMRF error: 0.043997823724759084\n"
]
}
],
"source": [
"import dolfin as df\n",
"\n",
"class Left(df.SubDomain):\n",
" def inside(self, x, on_boundary):\n",
" return on_boundary and x[0] < df.DOLFIN_EPS\n",
"\n",
"left = Left()\n",
"\n",
"boundaries = df.MeshFunction(\"size_t\", poisson.mesh, poisson.mesh.topology().dim()-1)\n",
"boundaries.set_all(0)\n",
"left.mark(boundaries, 1)\n",
"\n",
"ds_left = df.Measure('ds', domain=poisson.mesh, subdomain_data=boundaries)\n",
"\n",
"\n",
"b_exact = df.Function(poisson.V)\n",
"\n",
"ub_left = df.Expression(\"1.0*(x[1]<0.6)*(x[1]>0.4)+0.0\", degree=1)\n",
"bc_left = df.DirichletBC(poisson.V, ub_left, boundaries, 1)\n",
"\n",
"bc_left.apply(b_exact.vector())\n",
"\n",
"b_gmrf_tv = df.Function(poisson.V)\n",
"b_gmrf_tv.vector()[poisson.left_bc_dofs] = samples_rgmrf_tv.mean()\n",
"print(\"GMRF-TV error:\", df.assemble((b_gmrf_tv-b_exact)**2*ds_left))\n",
"\n",
"b_gmrf = df.Function(poisson.V)\n",
"b_gmrf.vector()[poisson.left_bc_dofs] = samples_gmrf_smaller.mean()\n",
"print(\"GMRF error:\", df.assemble((b_gmrf-b_exact)**2*ds_left))"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"95% CI width of GMRF-TV samples: 0.19552230112611954\n",
"95% CI width of GMRF samples: 1.056971041748038\n"
]
}
],
"source": [
"print(\"95% CI width of GMRF-TV samples: \", samples_rgmrf_tv.ci_width().mean())\n",
"print(\"95% CI width of GMRF samples: \", samples_gmrf_smaller.ci_width().mean())"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Standard deviation of GMRF-TV samples: 0.05014208230930131\n",
"Standard deviation of GMRF samples: 0.27113676535276054\n"
]
}
],
"source": [
"print(\"Standard deviation of GMRF-TV samples: \", samples_rgmrf_tv.std().mean())\n",
"print(\"Standard deviation of GMRF samples: \", samples_gmrf_smaller.std().mean())"
]
}
],
"metadata": {
Expand Down
106 changes: 96 additions & 10 deletions pde_source/source_1d_03.ipynb

Large diffs are not rendered by default.

106 changes: 96 additions & 10 deletions pde_source/source_1d_1.ipynb

Large diffs are not rendered by default.

106 changes: 96 additions & 10 deletions pde_source/source_1d_3.ipynb

Large diffs are not rendered by default.