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

CGLS: deprecate tolerance #1892

Merged
merged 11 commits into from
Aug 22, 2024

Conversation

MargaretDuff
Copy link
Member

@MargaretDuff MargaretDuff commented Aug 13, 2024

Changes

  • Updated doc strings for CGLS
  • Deprecated early stopping tolerances for CGLS - Note that I have broken backwards compatibility as early stopping based on tolerance is no longer done by default. I have left tolerance as a kwarg here to keep backwards compatibility if users have a custom tolerance with a plan to deprecate this fully in a later version.
  • Written new unit tests for CGLS
  • Added two new callbacks which can be used instead of passing a tolerance directly to CGLS
  • Added unit tests for the new callbacks

Testing you performed

Please add any demo scripts to https://github.com/TomographicImaging/CIL-Demos/tree/main/misc

Related issues/links

Closes #1891, closes #1894

Checklist

  • I have performed a self-review of my code
  • I have added docstrings in line with the guidance in the developer guide
  • I have updated the relevant documentation
  • 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 MargaretDuff changed the title Updated CGLS documentation, making default tolerance clearer CGLS: unit tests and deprecate tolerance Aug 15, 2024
@MargaretDuff MargaretDuff marked this pull request as ready for review August 15, 2024 12:10
@MargaretDuff MargaretDuff self-assigned this Aug 15, 2024
@MargaretDuff MargaretDuff changed the title CGLS: unit tests and deprecate tolerance CGLS: deprecate tolerance Aug 15, 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.

Just a small suggestion on the comments.

Please also create a new issue akin to #1443 linking the code, stating which version it was marked as deprecated in and suggesting removal for v25 (or 26?)

Copy link
Contributor

@jakobsj jakobsj left a comment

Choose a reason for hiding this comment

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

Just a few minor comments and questions, but generally looks good to me.

Wrappers/Python/cil/optimisation/algorithms/CGLS.py Outdated Show resolved Hide resolved
Wrappers/Python/cil/optimisation/algorithms/CGLS.py Outdated Show resolved Hide resolved
Wrappers/Python/cil/optimisation/algorithms/CGLS.py Outdated Show resolved Hide resolved
Wrappers/Python/cil/optimisation/algorithms/CGLS.py Outdated Show resolved Hide resolved
Wrappers/Python/cil/optimisation/utilities/callbacks.py Outdated Show resolved Hide resolved
Wrappers/Python/cil/optimisation/utilities/callbacks.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.

All looks good to me.

Copy link
Contributor

@jakobsj jakobsj left a comment

Choose a reason for hiding this comment

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

THanks for addressing the comments and in particular splitting to two separate tolerances and adding the explanation of historical CIL usage and original source. Approving with a few very minor suggestions.

Wrappers/Python/cil/optimisation/utilities/callbacks.py Outdated Show resolved Hide resolved
Wrappers/Python/cil/optimisation/utilities/callbacks.py Outdated Show resolved Hide resolved
Wrappers/Python/cil/optimisation/utilities/callbacks.py Outdated Show resolved Hide resolved
Wrappers/Python/cil/optimisation/utilities/callbacks.py Outdated Show resolved Hide resolved
@MargaretDuff MargaretDuff added the Merge pending jenkins Once jenkins is happy with can be merged label Aug 22, 2024
@MargaretDuff
Copy link
Member Author

Jenkins is happy

image

@MargaretDuff MargaretDuff merged commit 6d9978b into TomographicImaging:master Aug 22, 2024
8 checks passed
@MargaretDuff MargaretDuff deleted the cgls-tolerances branch August 22, 2024 09:12
Comment on lines +139 to +152
class EarlyStoppingObjectiveValue(Callback):
'''Callback that stops iterations if the change in the objective value is less than a provided threshold value.

Parameters
----------
threshold: float, default 1e-6

Note
-----
This callback only compares the last two calculated objective values. If `update_objective_interval` is greater than 1, the objective value is not calculated at each iteration (which is the default behaviour), only every `update_objective_interval` iterations.

'''
def __init__(self, threshold=1e-6):
self.threshold=threshold
Copy link
Member

Choose a reason for hiding this comment

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

VERY strongly disapprove of this. Far superior naming, vis. https://keras.io/api/callbacks/early_stopping/:

  • EarlyStopping, EarlyStoppingObjectiveDelta, EarlyStoppingObjectiveDelta, EarlyStoppingObjectiveChange
  • delta, change

@casperdcl casperdcl mentioned this pull request Sep 3, 2024
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Merge pending jenkins Once jenkins is happy with can be merged
Projects
None yet
4 participants