tffm icon indicating copy to clipboard operation
tffm copied to clipboard

How to save a trained model?

Open akshit96 opened this issue 6 years ago • 6 comments

How can I save a trained tffm for future predictions ? The model object cannot be pickled due to thread.RLock type object and isn't json serializable either.

akshit96 avatar Apr 03 '18 13:04 akshit96

Hi @akshit96, it cannot be pickled right now (there is a PR about this, but I haven't merded in yet), but in example.ipynb there is an example of how to save/restore the model.

geffy avatar Apr 10 '18 18:04 geffy

Any ideas how to save model for tf serving? Examples provide only python model saving and loading. But I do not want to use python for already trained model.

lukashes avatar Jun 26 '18 09:06 lukashes

You can save bias, weights, vectors in a file and calculate the prediction manually.

akshit96 avatar Jun 26 '18 09:06 akshit96

According to this answer https://stackoverflow.com/a/47982699/1579570 it is does not seem easy. May be better to use SavedModel inside?

lukashes avatar Jun 26 '18 11:06 lukashes

I did by saving the weights and predicting manually in a java code. It worked.

akshit96 avatar Jun 26 '18 11:06 akshit96

This is what we do and it works fine.

skymonkey avatar Dec 13 '18 14:12 skymonkey