question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Save, load and save again

See original GitHub issue

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__()?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
FrancoisDatacommented, 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"
2reactions
yurkovakcommented, Aug 17, 2020

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"
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Save and Load Your Keras Deep Learning Model
In this post, you will discover how to save your Keras models to files and load them up again to make predictions.
Read more >
Save and load Keras models | TensorFlow Core
APIs for saving weights to disk & loading them back. Weights can be saved to disk by calling model.save_weights in the following formats:....
Read more >
A quick complete tutorial to save and restore Tensorflow models
Update: This popular article shows how to save and restore models in Tensorflow 1.x. ... Otherwise, please follow this tutorial and come back...
Read more >
Save and load models in Tensorflow - GeeksforGeeks
Ways we can save and load our machine learning model are as follows: ... dataset and finally save and load the model again...
Read more >
Save and Load a Model with TensorFlow's Keras API
This method of saving will save everything about the model – the architecture, the weights, the optimizer, the state of the optimizer, the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found