geffy / tffm

TensorFlow implementation of an arbitrary order Factorization Machine
MIT License
780 stars 176 forks source link

How to save a trained model? #39

Open akshit96 opened 6 years ago

akshit96 commented 6 years ago

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.

geffy commented 6 years ago

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.

lukashes commented 6 years ago

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.

akshit96 commented 6 years ago

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

lukashes commented 6 years ago

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

akshit96 commented 6 years ago

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

skymonkey commented 5 years ago

This is what we do and it works fine.