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

Updates to PDHG and SPDHG notebooks #134

Closed
Closed
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
699 changes: 649 additions & 50 deletions demos/1_Introduction/04_FBP_CGLS_SIRT.ipynb

Large diffs are not rendered by default.

371 changes: 321 additions & 50 deletions demos/2_Iterative/01_optimisation_gd_fista.ipynb

Large diffs are not rendered by default.

210 changes: 182 additions & 28 deletions demos/2_Iterative/03_PDHG.ipynb

Large diffs are not rendered by default.

53 changes: 28 additions & 25 deletions demos/2_Iterative/04_SPDHG.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,6 @@
"from cil.plugins.ccpi_regularisation.functions import FGP_TV\n",
" \n",
"from cil.utilities.display import show2D\n",
"from cil.utilities.jupyter import islicer\n",
" \n",
" \n",
"import numpy as np\n",
Expand Down Expand Up @@ -259,31 +258,32 @@
"# Define number of subsets\n",
"n_subsets = 10\n",
"\n",
"# Initialize the lists containing the F_i's and A_i's\n",
"#Sequentially partition the data into the number of subsets using the data partitioner\n",
"partitioned_data=data.partition(n_subsets, 'sequential')\n",
"\n",
"\n",
"# Initialize the lists containing the F_i's\n",
"f_subsets = []\n",
"A_subsets = []\n",
"\n",
"# Define F_i's and A_i's\n",
"\n",
"# Define F_i's\n",
"for i in range(n_subsets):\n",
" # Total number of angles\n",
" n_angles = len(ag2D.angles)\n",
" # Divide the data into subsets\n",
" data_subset = Slicer(roi = {'angle' : (i,n_angles,n_subsets)})(data)\n",
" # Define F_i and put into list\n",
" fi = 0.5*L2NormSquared(b = data_subset)\n",
" fi = 0.5*L2NormSquared(b = partitioned_data[i])\n",
" f_subsets.append(fi)\n",
" # Define A_i and put into list \n",
" ageom_subset = data_subset.geometry\n",
" Ai = ProjectionOperator(ig2D, ageom_subset)\n",
" A_subsets.append(Ai)\n",
"\n",
"# Define F and K\n",
" \n",
"# Define F \n",
"F = BlockFunction(*f_subsets)\n",
"K = BlockOperator(*A_subsets)\n",
"\n",
"\n",
"#Create the projection operator, K, for the partitioned data\n",
"ageom_subset = partitioned_data.geometry\n",
"K = ProjectionOperator(ig2D, ageom_subset)\n",
"\n",
"\n",
"# Define G (by default the positivity constraint is on)\n",
"alpha = 0.025\n",
"G = alpha * FGP_TV()"
"G = alpha * FGP_TV()\n"
]
},
{
Expand Down Expand Up @@ -464,21 +464,24 @@
"# Define number of subsets\n",
"n_subsets = 10\n",
"\n",
"#We sequentially partition the data into the number of subsets using the data partitioner\n",
"partitioned_data=data.partition(n_subsets, 'sequential')\n",
"\n",
"\n",
"\n",
"# Initialize the lists containing the F_i's and A_i's\n",
"f_subsets = []\n",
"A_subsets = []\n",
"\n",
"\n",
"\n",
"# Define F_i's and A_i's - data fit part\n",
"for i in range(n_subsets):\n",
" # Total number of angles\n",
" n_angles = len(ag2D.angles)\n",
" # Divide the data into subsets\n",
" data_subset = Slicer(roi = {'angle' : (i,n_angles,n_subsets)})(data)\n",
" # Define F_i and put into list\n",
" fi = 0.5 * L2NormSquared(b = data_subset)\n",
" fi = 0.5 * L2NormSquared(b = partitioned_data[i])\n",
" f_subsets.append(fi)\n",
" # Define A_i and put into list \n",
" ageom_subset = data_subset.geometry\n",
" ageom_subset = partitioned_data[i].geometry\n",
" Ai = ProjectionOperator(ig2D, ageom_subset)\n",
" A_subsets.append(Ai)\n",
" \n",
Expand All @@ -498,7 +501,7 @@
"\n",
"# Setup and run SPDHG for 5 epochs\n",
"spdhg_explicit = SPDHG(f = F, g = G, operator = K, max_iteration = 5 * 2 * n_subsets,\n",
" update_objective_interval = 2 * n_subsets)\n",
" update_objective_interval = 2 * n_subsets, prob=prob )\n",
"spdhg_explicit.run()"
]
},
Expand Down Expand Up @@ -693,7 +696,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.13"
"version": "3.8.17"
}
},
"nbformat": 4,
Expand Down