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.

How to save and load experiment/model from `optimize`

See original GitHub issue

Hi, from the documentation, the optimize function returns the (best_parameters, values, experiment, model) tuple. I’m wondering what’s the best practices for saving these values (e.g. for visualization in a different machine)? Also, is it possible to interrupt a model and later resume from the state in the optimize API? Thanks!

Issue Analytics

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

github_iconTop GitHub Comments

3reactions
lena-kashtelyancommented, Jul 13, 2020

Hi, @ksanjeevan, @theinlinaung2010! Sorry to have missed your tags, the issue was closed so we weren’t notified in time. Feel free to reopen the issue if there is a follow-up, in the future, to make sure we get back to you as soon as we can!

For 2), you can use get_best_parameters utility to find the best point on the experiment. You can also use exp_to_df to view the trials in your experiment as a convenient dataframe. Let me know if those don’t fully address your concern!

To use storage functionality for experiment and models used in optimization, I would recommend using our Service API that is well integrated with our storage layer (you can store locally to a .json file or to an SQL backend). You can check out our API comparison code snippets and the Service API tutorial to see how to get started and how to leverage storage.

Let us know if you have further questions, I’ll keep the issue open for now.

2reactions
ldworkincommented, Apr 7, 2021

Hi @nwrim ! The easiest way to accomplish what you want is probably to save the data that you’re using to fit the model (rather than the model itself), and then you can refit it whenever you want. If you want to take advantage of Ax’s storage to do so, you would use experiment.attach_data() followed by save_experiment. Then you can use load_experiment and experiment.lookup_data_for_trial or experiment.lookup_data_for_ts at a later point to grab that data again and refit the model. Does that sound like it would help?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Save, Load and Resume Experiments - garage - Read the Docs
In general, loading models and resuming an experiment includes the following steps: Initialize the Trainer / TFTrainer instance. Restore the algorithm and ...
Read more >
Save and Load Machine Learning Models in Python with scikit ...
This article shows how to save a model that is built from scratch. But I am looking to train the model by including...
Read more >
How to Save and Load Models in PyTorch - Wandb
This article is a tutorial that covers how to correctly save and load your trained machine learning models in PyTorch using Weights &...
Read more >
How to save and load a Gurobi model and solution without ...
There may be a pretty simple answer to your question: it seems you are missing the modelLoaded.optimize() call. Even when "loading a solution" ......
Read more >
Guide to model training — Part 6: Save & Load
The simplest way to save a model is as a byte object tied directly to a variable. This can be useful if you...
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