-
Notifications
You must be signed in to change notification settings - Fork 43
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
New callback to save a list of iterates every set number of iterations #1913
base: master
Are you sure you want to change the base?
New callback to save a list of iterates every set number of iterations #1913
Conversation
Signed-off-by: Margaret Duff <[email protected]>
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.
In the Petric challenge they have the callback: class SaveIters(Callback):
"""Saves `algo.x` as "iter_{algo.iteration:04d}.hv" and `algo.loss` in `csv_file`"""
def __init__(self, outdir=OUTDIR, csv_file='objectives.csv', **kwargs):
super().__init__(**kwargs)
self.outdir = Path(outdir)
self.outdir.mkdir(parents=True, exist_ok=True)
self.csv = csv.writer((self.outdir / csv_file).open("w", buffering=1))
self.csv.writerow(("iter", "objective"))
def __call__(self, algo: Algorithm):
if not self.skip_iteration(algo):
log.debug("saving iter %d...", algo.iteration)
algo.x.write(str(self.outdir / f'iter_{algo.iteration:04d}.hv'))
self.csv.writerow((algo.iteration, algo.get_last_loss()))
log.debug("...saved")
if algo.iteration == algo.max_iteration:
algo.x.write(str(self.outdir / 'iter_final.hv')) This also saves the loss in a CSV file. I like that the file name it has the iteration number. I am not sure we can do this with our current TiffWriter? |
a910556
to
f8b513b
Compare
Co-authored-by: Casper da Costa-Luis <[email protected]> Signed-off-by: Margaret Duff <[email protected]>
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.
Thanks @casperdcl - is it the naming that you want to change? |
Signed-off-by: Margaret Duff <[email protected]>
Changes
New callback to save a list of iterates every set number of iterations
Testing you performed
Related issues/links
Closes #1909
Checklist
Contribution Notes
Please read and adhere to the developer guide and local patterns and conventions.