-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
How to save VAE model #328
Comments
I just searched around and realize lambda layer is very fragile. we will have to replace that with a custom layer. |
for self-reference: keras-team/keras#6442 |
I solve this problem. While saving the paramters of VAE model, I also save the the initial parameters of VAE class at the same time. |
I can't save Deep svdd model, Could you tell me how you saved VAE model? |
As the poster of the issue said, you save the model first, then you save the class. In the VAE class, there is a build model function. In fit function, it calls the build model function and assign it to self.model_. What you need to do is that you first use keras.save to save the self.model_. Then you make self.model_ = None. Then you can joblib.dump the whole class. When you load, you first use joblib.load to load the class, then you use keras.load to load self.model_. And you put self.model_ inside the class. But this will cause error. As I searched, when you are loading the keras model, you need to load the custome Lamda function inside the Lamda layer which is self.sampling. So what you need to do is that copy the self.sampling function in your file, and load it using custome object. The order looks like this: joblib.dump(your VAE class, path) Load: It works for me. But it needs some testing. At least there is no error saving and loading. |
@jjjzy Thanks for this information. This sounds like a workaround for now. |
Thanks for your help. |
兄弟,能分享下代码吗谢谢 |
I have a problem when I want to save the VAE model after the training. This is because this
Specifically, the
Lambda
layer cannot be saved into file. Could you give me any advice to save it?The text was updated successfully, but these errors were encountered: