OdysseasKr / neural-disaggregator

Code for NILM experiments using Neural Networks. Uses Keras/Tensorflow and the NILMTK.
MIT License
138 stars 58 forks source link

Pickle the model #14

Closed ikrambennasrbennasr closed 5 years ago

ikrambennasrbennasr commented 5 years ago

Hi @OdysseasKr , To pickle the model, should I pickle the all disaggregator? Thanks

OdysseasKr commented 5 years ago

I haven't tried to use pickle with the disaggregators so I don't know how well it would work. I don't see any reason why it shouldn't work like this.

Keep in mind that the model parameter of the disaggregator is a Keras Sequential object.

ikrambennasrbennasr commented 5 years ago

Hi @OdysseasKr . Thanks for your response. In fact, I wanted to deploy the model with AWS Sagemaker. And to import a model into a sagemaker, in general it uses the .pkl format, that's why I wanted to pickle the model. I just wanted to know if the model accepts importaion as .pkl model. And according to my research, a keras sequential model can be also be pickled. What I did is:

import pickle pickle.dump(disaggregator,open('mymodel.pkl', 'wb')) cls=pickle.load(open('mymodel.pkl', 'rb'))

After doing that, cls has all the methods that the disaggregator has, so in my opinion it works well. I don't know, if I have the right to talk about sagemaker by opening an issue here. But I just wanted to check the pickle function. And thank you for your understanding.

OdysseasKr commented 5 years ago

I guess that only the model attribute of the disaggregator is required for the deployment with Sagemaker. I haven't tried it myself though so don't take my word for it.

If you manage to get it working let me know so that we can possible add the functionality. Or you can submit a pull request yourself.