-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from openspyrit/Adapted_Examples
Adapted examples with updates in Preprocess Test and Tutorial
- Loading branch information
Showing
10 changed files
with
2,345 additions
and
1,119 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 1, | ||
"id": "d76177d5-8be7-4c30-9c67-73db868ec9da", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import torch\n", | ||
"import numpy as np\n", | ||
"from spyrit.core.Acquisition import *\n", | ||
"from spyrit.core.Forward_Operator import *\n", | ||
"from spyrit.misc.walsh_hadamard import walsh_matrix" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "344ef094-8f2b-4cd3-8327-5bb12dfe141b", | ||
"metadata": {}, | ||
"source": [ | ||
"## Instantiate Hsub" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 2, | ||
"id": "da911fa8-10f7-483d-9ddd-a657d7f6ebe3", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"img_size = 32*32\n", | ||
"nb_measurements = 400\n", | ||
"batch_size = 10\n", | ||
"Hcomplete = walsh_matrix(img_size)\n", | ||
"Hsub = Hcomplete[0:nb_measurements,:]" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "4fd3ef2b-4445-41c5-aa9d-8f43714743b3", | ||
"metadata": {}, | ||
"source": [ | ||
"## Acquisition" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 3, | ||
"id": "19a09413-6d99-4057-a827-1f5504ebf386", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"torch.Size([10, 400])\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"x = torch.tensor(np.random.random([batch_size,img_size]), dtype=torch.float)\n", | ||
"FO = Forward_operator(Hsub)\n", | ||
"Acq = Acquisition(FO)\n", | ||
"y = Acq(x)\n", | ||
"print(y.shape)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "94a2221f-f741-4e56-aecb-a2962e1bc52e", | ||
"metadata": {}, | ||
"source": [ | ||
"## Acquisition_Poisson_approx_Gauss" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 4, | ||
"id": "83fa4f1c-6061-4c39-a9f8-d2ddda563cd3", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"torch.Size([10, 400])\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"Acq_Poisson_approx_Gauss = Acquisition_Poisson_approx_Gauss(9, FO)\n", | ||
"y = Acq_Poisson_approx_Gauss(x)\n", | ||
"print(y.shape)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "ba063a79-bc41-46b2-bac6-ea9bc738bd8d", | ||
"metadata": {}, | ||
"source": [ | ||
"## Acquisition_Poisson_Pytorch" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": 5, | ||
"id": "e0c037fd-7722-44bd-baed-9c6faeafce88", | ||
"metadata": {}, | ||
"outputs": [ | ||
{ | ||
"name": "stdout", | ||
"output_type": "stream", | ||
"text": [ | ||
"torch.Size([10, 400])\n" | ||
] | ||
} | ||
], | ||
"source": [ | ||
"Acq_Poisson = Acquisition_Poisson(9, FO)\n", | ||
"y = Acq_Poisson(x)\n", | ||
"print(y.shape)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.9.7" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |
Oops, something went wrong.