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

Spdhg with stochastic sampler #1644

Merged
merged 144 commits into from
Nov 25, 2024

Conversation

MargaretDuff
Copy link
Member

@MargaretDuff MargaretDuff commented Jan 10, 2024

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 <43645617+MargaretDuff@users.noreply.github.com>
@lauramurgatroyd lauramurgatroyd removed this from the v24.2.0 milestone Sep 24, 2024
Copy link
Member

@gfardell gfardell left a comment

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.

Wrappers/Python/cil/optimisation/algorithms/SPDHG.py Outdated Show resolved Hide resolved
Wrappers/Python/cil/optimisation/algorithms/SPDHG.py Outdated Show resolved Hide resolved
Wrappers/Python/cil/optimisation/algorithms/SPDHG.py Outdated Show resolved Hide resolved
Wrappers/Python/cil/optimisation/algorithms/SPDHG.py Outdated Show resolved Hide resolved
Wrappers/Python/cil/optimisation/algorithms/SPDHG.py Outdated Show resolved Hide resolved
Wrappers/Python/cil/optimisation/algorithms/SPDHG.py Outdated Show resolved Hide resolved
Copy link
Member

@gfardell gfardell left a comment

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!

Wrappers/Python/test/test_algorithms.py Show resolved Hide resolved
Wrappers/Python/test/test_algorithms.py Show resolved Hide resolved
Wrappers/Python/test/test_algorithms.py Show resolved Hide resolved
Wrappers/Python/test/test_algorithms.py Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
@MargaretDuff MargaretDuff merged commit 411c679 into TomographicImaging:master Nov 25, 2024
8 of 9 checks passed
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