geffy / tffm

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

Save / load Model #25

Closed LombardiLeandro closed 7 years ago

LombardiLeandro commented 7 years ago

Hi,

I've been using TFFM for prototyping and is great, thank you. It is actually one of my first experiences with TF.

I found there is no direct save/load for a TFFM model. If there is, ignore this post completely :)

I understand you can save/load underlying TF objects. More precisely, say I have a model = TFFMRegressor( ... ) that I want to save and load.

So, my workaround is: -> Save: underlying TF objects via: model.core.saver.save(model.session, 'filename')

-> Load: 1) Create an (almost) identical model = TFFMRegressor( ..., n_epochs=1 ) 2) Train for 1 epoch with model.fit() 3) Retrieving TF graph and Session with saver = tf.train.import_meta_graph('filename.meta') saver.restore(model.session, tf.train.latest_checkpoint('./'))

First of all, since I am not very experienced in TF, I do not know if this is even enough / correct.

Then, I would like to suggest a .save() and .load() method for TFFM models.

geffy commented 7 years ago

Hi, there is a already implemented way to save model very similar to what you described: https://github.com/geffy/tffm/blob/master/tffm/base.py#L251-L258

You can also find usage example in example.ipynb

LombardiLeandro commented 7 years ago

Thanks! somehow I didn't realize it was there and how to use it.

On Wed, Jun 14, 2017 at 3:53 AM Mikhail Trofimov notifications@github.com wrote:

Hi, there is a already implemented way to save model very similar to what you described: https://github.com/geffy/tffm/blob/master/tffm/base.py#L251-L258

You can also find usage example in example.ipynb

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/geffy/tffm/issues/25#issuecomment-308336692, or mute the thread https://github.com/notifications/unsubscribe-auth/AXbhKDHeRNT5AfBu3-hItlvnVJgTSol_ks5sD4NzgaJpZM4N5B5s .