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.

BUG: can't grid search optimizers

See original GitHub issue

It turns out that Keras optimizers are not picklable because they use lambdas inside functions 🤦

This can be fixed by using tf.keras.optimizers.serialize and tf.keras.optimizers.deserialize.

I think that maybe we need to list out all of the keras object types Model, optimizers, callbacks, etc. and use copyreg.pickle to register how to pickle each one using their custom keras serialize/deserialize methods.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
adriangbcommented, Nov 5, 2020

So the RFC was approved on the Keras end, but it did not cover the specific use case here, which includes optimizers, losses, metrics and callbacks. The pushback on these was mainly surrounding optimizers, given that there is no singular “official” API for serializing optimizers with their weights. Instead, we would have to call tf.keras.optimizers.Optimizer.get_weights/tf.keras.optimizers.Optimizer.set_weights.

We may not be able to upstream this since there is no clear use case in Keras for serializing optimizers, callbacks, etc. outside of a Model.

0reactions
adriangbcommented, Jan 20, 2021

Resolved by #128

Read more comments on GitHub >

github_iconTop Results From Across the Web

I can't add optimizer parameter in gridsearch - Stack Overflow
I wanna test the model with different optimizer. But I can't seem to add optimizer in grid search. Whenever I run the program,...
Read more >
Are You Still Using Grid Search for Hyperparameters ...
Are You Still Using Grid Search for Hyperparameters Optimization? Let's discuss the ideas behind how to search in a smart fashion the ...
Read more >
How to Grid Search Hyperparameters for Deep Learning ...
Grid search is a model hyperparameter optimization technique. ... I am experiencing the same error “can't pickle _thread.
Read more >
Error when Keras model is used in grid search ... - GitHub
Hi all, I understand KerasClassifier can be used to wrap a Keras model and input to grid_search/cross_val_score in scikit-learn. But I can't ......
Read more >
Is it possible to get worse model after optimization?
Secondly, a grid search where you don't really know where to look should contain a much larger variance for the parameters.
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