Skip to content

Spdhg with stochastic sampler - #1644

Merged
MargaretDuff merged 144 commits into
TomographicImaging:masterfrom
MargaretDuff:spdhg_sampler
Nov 25, 2024
Merged

Spdhg with stochastic sampler#1644
MargaretDuff merged 144 commits into
TomographicImaging:masterfrom
MargaretDuff:spdhg_sampler

Conversation

@MargaretDuff

@MargaretDuff MargaretDuff commented Jan 10, 2024

Copy link
Copy Markdown
Member

Describe your changes

  • Allow SPDHG to take a sampler either from our sampler class or any class with a next(self) function
  • Deprecated prob from SPDHG, taking the probabilities instead from the sampler class or from a new argument prob_weights, choosing the default [1/num_subsets]*num_subsets if one is not provided in either place.
  • Created two setters for the step sizes. set_step_sizes_from_ratio resets the step sizes if the user provides one/both/none of gamma and rho - note that this closes SPDHG gamma parameter is applied incorrectly  #1860. step_sizes_custom takes in one/both/none of sigma and tau allowing the user to use a custom sigma and tau with those not provided calculated from the defaults. Calculating sigma from tau probably needs checking with someone else.
  • Added a check_convergence function that checks self._sigma[i] * self._tau * self.norms[i]**2 <= self.prob_weights[i] for all i. This probably needs checking with someone else.
  • Deprecated the kwarg "norms" to be replaced by the set_norms method in BlockOperator: added a function to return a list of norms and the ability to set this list of norms BlockOperator: added a function to return a list of norms and the ability to set this list of norms BlockOperator: added a function to return a list of norms and the ability to set this list of norms  #1513.
  • Unit tests for SPDHG setters and convergence check

Describe any testing you have performed

Please add any demo scripts to CIL-Demos/misc/
Test with SPDHG https://github.com/TomographicImaging/CIL-Demos/blob/main/misc/testing_sampling_SPDHG.ipynb

Similar results gained for all samplers for SPDHG, with 10 subsets
image

With 80 subsets:
image

Link relevant issues

Part of the stochastic work plan. Closes #1575. Closes #1576. Closes #1500. Closes #1496

Checklist when you are ready to request a review

  • I have performed a self-review of my code
  • I have added docstrings in line with the guidance in the developer guide
  • I have implemented unit tests that cover any new or modified functionality
  • CHANGELOG.md has been updated with any functionality change
  • Request review from all relevant developers
  • Change pull request label to 'Waiting for review'

Contribution Notes

Please read and adhere to the developer guide and local patterns and conventions.

  • The content of this Pull Request (the Contribution) is intentionally submitted for inclusion in CIL (the Work) under the terms and conditions of the Apache-2.0 License.
  • I confirm that the contribution does not violate any intellectual property rights of third parties

MargaretDuff and others added 30 commits August 2, 2023 10:36
Quick docstring

Signed-off-by: Margaret Duff <[email protected]>
@lauramurgatroyd lauramurgatroyd removed this from the v24.2.0 milestone Sep 24, 2024
Comment thread Wrappers/Python/cil/optimisation/algorithms/SPDHG.py Outdated
Comment thread Wrappers/Python/cil/optimisation/algorithms/SPDHG.py Outdated
Comment thread Wrappers/Python/cil/optimisation/algorithms/SPDHG.py Outdated
Comment thread Wrappers/Python/cil/optimisation/algorithms/SPDHG.py Outdated
Comment thread Wrappers/Python/cil/optimisation/algorithms/SPDHG.py Outdated
Comment thread Wrappers/Python/cil/optimisation/algorithms/SPDHG.py Outdated
Comment thread Wrappers/Python/cil/optimisation/algorithms/SPDHG.py Outdated
Comment thread Wrappers/Python/cil/optimisation/algorithms/SPDHG.py Outdated
Comment thread Wrappers/Python/cil/optimisation/algorithms/SPDHG.py Outdated
Comment thread Wrappers/Python/cil/optimisation/algorithms/SPDHG.py
Comment thread Wrappers/Python/cil/optimisation/algorithms/SPDHG.py Outdated

@gfardell gfardell left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly docstring clarification. I think it's very close.

Comment thread Wrappers/Python/cil/optimisation/algorithms/SPDHG.py Outdated
Comment thread Wrappers/Python/cil/optimisation/algorithms/SPDHG.py Outdated
Comment thread Wrappers/Python/cil/optimisation/algorithms/SPDHG.py Outdated
Comment thread Wrappers/Python/cil/optimisation/algorithms/SPDHG.py Outdated
Comment thread Wrappers/Python/cil/optimisation/algorithms/SPDHG.py Outdated
Comment thread Wrappers/Python/cil/optimisation/algorithms/SPDHG.py Outdated

@gfardell gfardell left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of changes to the unit tests. But I'm happy for you to merge when you're happy!

Comment thread Wrappers/Python/test/test_algorithms.py
Comment thread Wrappers/Python/test/test_algorithms.py
Comment thread Wrappers/Python/test/test_algorithms.py
Comment thread Wrappers/Python/test/test_algorithms.py Outdated
Comment thread CHANGELOG.md Outdated
@MargaretDuff
MargaretDuff merged commit 411c679 into TomographicImaging:master Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

No open projects
Status: Needs reviewing
Status: PRs to review

4 participants