Skip to content

Commit

Permalink
Merge pull request #22 from openspyrit/Adapted_Examples
Browse files Browse the repository at this point in the history
Adapted examples with updates in Preprocess Test and Tutorial
  • Loading branch information
tbaudier authored Jan 31, 2023
2 parents c1e24ce + de16955 commit da210bd
Show file tree
Hide file tree
Showing 10 changed files with 2,345 additions and 1,119 deletions.
471 changes: 0 additions & 471 deletions Debug_version_2/Acqusition_debug.ipynb

This file was deleted.

594 changes: 0 additions & 594 deletions Debug_version_2/Forward_operator_debug.ipynb

This file was deleted.

147 changes: 147 additions & 0 deletions Debug_version_2/Test_Acquisition.ipynb
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
}
Loading

0 comments on commit da210bd

Please sign in to comment.