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

Save, load and save again #159

Closed
rm-rf0 opened this issue Apr 22, 2019 · 6 comments · Fixed by #230
Closed

Save, load and save again #159

rm-rf0 opened this issue Apr 22, 2019 · 6 comments · Fixed by #230

Comments

@rm-rf0
Copy link

rm-rf0 commented Apr 22, 2019

Hi,

Thanks for this useful library!

I wonder how to do save - load - save - load multiple times?
To achieve this, I use the code below:

if os.path.exists(log_path):
    load_logs(optimizer, logs=[log_path])
    print('Load {} records from disk.'.format(len(optimizer.space)))

logger = JSONLogger(path=log_path)
optimizer.subscribe(Events.OPTMIZATION_STEP, logger)

But it seems that this line

logger = JSONLogger(path=log_path)

will delete the orginal json file and previous records are lost.

Why do we need to do os.remove(self._path) in JSONLogger.__init__()?

@fmfn
Copy link
Member

fmfn commented Apr 22, 2019

Good point, maybe we don't. Let me take a look and try to remember if I had a good reason to add it. If not I can remove it. In the meantime, feel free to submit a PR.

@bionicles
Copy link

bionicles commented Jun 15, 2019

this messes it up for us, because it deletes our logs!

@fmfn it might be good to check if the bounds changed, and only replace the logs if they did, and also critically to rename the logs file instead of deleting it, because that data is valuable, and it's just getting tossed out

@bionicles
Copy link

bionicles commented Jun 16, 2019

@fmfn
more thoughts ... I think this package is gonna accelerate deep learning research greatly, but I would request one change to the logs system:

Instead of rewriting the logs file and passing a filepath, is it too hard to pass a logs folder? Then we could save timestamped logs which might be useful for reproducability and publications. I think if the first line of the logs file contained the "Bounds" information, then bayesopt can easily compare the current bounds, to the bounds of the previous logs in the logs folder, and just pick the most recent logs with the same bounds. So if you pass new bounds, it starts a new log file, but if you use bounds from before, it picks where it left off. Is this hard to implement?

@KaleabTessera
Copy link

Any feedback on this? I am still unsure as how to save - load - save again. Once I load the logs and save, it clears the logs and all history of past probes. Won't this affect the underlying GP?

@FrancoisData
Copy link

FrancoisData commented Jan 29, 2020

Hi,
While it's not save you can just add the following lines in your code:

class newJSONLogger(JSONLogger) :

      def __init__(self, path):
            self._path=None
            super(JSONLogger, self).__init__()
            self._path = path if path[-5:] == ".json" else path + ".json"

@yurkovak
Copy link

For those who are wondering, the reset option from @AlbertAlonso isn't available in v1.2.0 yet, so it doesn't come with the installation from pip. In the meanwhile, thanks for this workaround!

Hi,
While it's not save you can just add the following lines in your code:

class newJSONLogger(JSONLogger) :

      def __init__(self, path):
            self._path=None
            super(JSONLogger, self).__init__()
            self._path = path if path[-5:] == ".json" else path + ".json"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants