Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pytorch notebook for Dec 2023 training #97

Merged
merged 1 commit into from
Dec 6, 2023
Merged
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
16 changes: 9 additions & 7 deletions training/Plugins/CUQIpy-PyTorch/CP01_HMC.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@
"metadata": {},
"outputs": [],
"source": [
"A, y_data, probinfo = cuqi.testproblem.Deconvolution1D(dim=50, phantom=\"sinc\").get_components()\n",
"A, y_data, probinfo = cuqi.testproblem.Deconvolution1D(dim=50, phantom=\"sinc\", use_legacy=True).get_components()\n",
"\n",
"# CUQIpy Bayesian model\n",
"x = cuqi.distribution.Gaussian(np.zeros(A.domain_dim), cov=0.2)\n",
Expand Down Expand Up @@ -792,7 +792,7 @@
"outputs": [],
"source": [
"# CUQIpy test problem\n",
"A, y_data, probinfo = cuqi.testproblem.Deconvolution1D(dim=50, phantom=\"sinc\").get_components()\n",
"A, y_data, probinfo = cuqi.testproblem.Deconvolution1D(dim=50, phantom=\"sinc\", use_legacy=True).get_components()\n",
"\n",
"# Add forward model to PyTorch automatic differentiation framework\n",
"A = cuqipy_pytorch.model.add_to_autograd(A)\n",
Expand All @@ -801,7 +801,9 @@
"x = Gaussian(xp.zeros(A.domain_dim), 0.2)\n",
"y = Gaussian(A(x), 0.05)\n",
"\n",
"samples = sample(x, y, y=y_data)"
"samples = sample(x, y, y=y_data)\n",
"\n",
"samples[\"x\"].plot_ci(exact=probinfo.exactSolution)"
]
},
{
Expand Down Expand Up @@ -831,7 +833,7 @@
"outputs": [],
"source": [
"# CUQIpy test problem\n",
"A, y_data, probinfo = cuqi.testproblem.Deconvolution1D(dim=50, phantom=\"sinc\").get_components()\n",
"A, y_data, probinfo = cuqi.testproblem.Deconvolution1D(dim=50, phantom=\"sinc\", use_legacy=True).get_components()\n",
"\n",
"# CUQIpy Bayesian model\n",
"x = cuqi.distribution.Gaussian(np.zeros(A.domain_dim), cov=0.2)\n",
Expand All @@ -841,7 +843,7 @@
"try:\n",
" samples = BP.sample_posterior(1000) # Sampling fails because of the nonlinearity\n",
"except Exception as e:\n",
" print(e)"
" print(e) # The error message could be improved"
]
},
{
Expand All @@ -859,7 +861,7 @@
"outputs": [],
"source": [
"# CUQIpy test problem\n",
"A, y_data, probinfo = cuqi.testproblem.Deconvolution1D(dim=50, phantom=\"sinc\").get_components()\n",
"A, y_data, probinfo = cuqi.testproblem.Deconvolution1D(dim=50, phantom=\"sinc\", use_legacy=True).get_components()\n",
"\n",
"# Add forward model to PyTorch automatic differentiation framework\n",
"A = cuqipy_pytorch.model.add_to_autograd(A)\n",
Expand Down Expand Up @@ -911,7 +913,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.9.11"
},
"orig_nbformat": 4,
"vscode": {
Expand Down