-
Notifications
You must be signed in to change notification settings - Fork 45
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
Algorithm.run(callbacks: list[Callback])
#1659
Conversation
Algorithm.run(callbacks: list[Callback])
Since you have a base
Although there are no classes atm for 1)-3), we use them in the Algorithm class for For example a) Compute SSIM given a reference image, b) Compute PSNR for a ROI, c) Compute Users can have access to a), b), c) similar to Finally, there is a problem with |
Nice ideas... we can do this in follow-up issues/PRs (also note that some of what you describe should be done by subclassing
added
Sounds like an unrelated follow-up issue? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good Casper - neatens things up and I think that it will be a great increase in functionality. I highlighted a few mostly doc-string changes. We also need to think about what changes are required in the optimisation.rst
file for the documentation
Would you be able to share an output example? |
added another screenshot to the PR description |
6e44e46
to
799bc21
Compare
thanks @MargaretDuff - I switched to "new-style" docstrings in the new |
The current
This output depends on 3 parameters:
I see a couple of issues with the proposed new default and
|
Following on from @paskino's comment. I am concerned that with the current default in "TextProgressCallback" the objective is only updated every |
|
That'd be great, I think. |
Thanks @casperdcl! That looks good to me |
using |
We also need to think about what changes are required in the optimisation.rst file to document the increased functionality |
fyi since I purged |
I think |
Describe your changes
utilities.callbacks
(afterutilities
was created in Stochastic sampler only #1642)Algorithm.run(callback: Callable)
in favour ofAlgorithm.run(callbacks: list[Callback])
Callback
(abstract base class)_OldCallback
(to wrap old-styledef callback(iteration, objective, x)
)ProgressCallback
based ontqdm.auto
TextProgressCallback
prints to screen on separate lines everyupdate_objective_interval
LogfileCallback
prints to fileEarlyStoppingCallback
works by doingraise StopIteration
- only added test & basic docstring mention for this, no full example.... because inheriting & overridingAlgorithm.should_stop
is probably better design in most cases, and also because a concreteEarlyStoppingCallback
use-case would be task-specific so deserves to be in CIL-Demos instead.Algorithm(**kwargs)
to raise errors on unsupported options (part of Use of **kwargs in methods and functions signature is confusing #1115)max_iteration
:old behaviour:
Algorithm().run(): TypeError(None)
Algorithm(max_iteration=10).run(): 10/10
Algorithm().run(iterations=5): 5/5
Algorithm(max_iteration=10).run(iterations=5): 5/5
Algorithm(max_iteration=5).run(iterations=10): 10/10
new behaviour:
1/1
but prints a warningAlgorithm().run(iterations)
is the only recommended way now.algo.run(5); alg.run(4)
will do5/5
followed by9/9
Algorithm(max_iteration)
Algorithm.run(iterations)
current = self.iteration
total = self.iteration + iterations
for step in range(current, total): progress = step/total * 100
Describe any testing you have performed
test_algorithms.TestCallbacks
TextProgressCallback(miniters=5)
Link relevant issues
Checklist when you are ready to request a review
Contribution Notes
Please read and adhere to the developer guide and local patterns and conventions.