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
Loading Best Model from File #41
Comments
My bad, I should have gone through the source code. For those who may stumble upon this, the way I found is to use the reload function. However, this still requires initialization of the tuner as it was done during the tuning process: So for example: Tuning:
Loading the best model in a new script:
Correct me if there are other/ better ways of doing this! |
I also did the same to access completed search but there should be another way. |
I was able to comeup with a workaround. Use the attached code to import results in another script
` example usage:
|
That is great. Looks much more elegant. Will check it out! |
That works and is indeed useful. Thank you! |
Generally what I'd advise for inference is to grab and persist the best hyperparameters from the Oracle, and then pass these hyperparameters to your For example:
|
Is this the desired behavior? Why can't |
@JakeTheWise it can and does But usually when doing hyperparameter tuning, you'll split the data into three sets: train, validation, and test You'll perform the hyperparameter search using the train set to train the model, and the validation set to evaluate hyperparameter performance Then you evaluate the generalization ability on the test set with either:
Since more data is almost always better, (2) is likely to give you better performance on the test set (and in production), but requires additional training time The idea of |
Understood! |
I need some help in extracting the best model before completing hyperparameter optimization. (using available trail files in the project directory) |
The documentation clearly explains the procedure for loading the best model after hypereparameter optimization is complete.
models = tuner.get_best_models(num_models=2)
Also the metrics/ predictions can be obtained with:
# Evaluate the best model. loss, accuracy = best_model.evaluate(x_val, y_val)
However, how do you load a pre-tuned model from file and how to get the best model to make predictions?
The text was updated successfully, but these errors were encountered: