2

My buddy and I are trying to utilize the trained model from the LSTM tensorflow example here. We've been able to train our model, save the model, and then import the model. We've just used tensorflow's Supervisor. It was in the tutorial, but you can read more about it here.

It's weird because there's not a whole lot of clear documentation for this. I understand that tensorflow is an API that's going through a lot of changes and adaptations right now, but it's hard to find clear answers. For example, we want to use tf.train.Saver(), but we aren't sure if there is anything comparable to tf.train.Supervisor()'s managed_session.

More to the point, however, we just want to use our model. We want to be able to map a string using tensorflow.models.rnn.ptb.reader. We're not sure how to do this. We pass in a string, and we want to do a simple prediction in terms of like predicting the next word in a string. So, something similar to this:

import tensorflow as tf
sess = tf.Session()
new_saver = tf.train.import_meta_graph('ptbmodel.meta')
new_saver.restore(sess, tf.train.latest_checkpoint('./')) # latest checkpoint
all_vars = tf.global_variables()
# just want to make sure all our variables are there!
for v in all_vars:
    v_ = sess.run(v)
    print("This is {} with value: {}".format(v.name, v_))


sent = raw_input("Enter a string where you want to predict the next word: ")
split_sent = sent.split()
# THEN map these words into our LSTM model and pull off the most likely word that 
# is coming next

But again, my buddy and I are pretty new to this, so we're not sure about where to go. I know this is probably too broad of a question for stack, but we've been pouring over the documentation and haven't been able to make much progress. ANY help would be appreciated so much!

We've already found these other Stack links. Check them out here and here.

We are not sure how to associate the logits probability list with any meaningful words.

Community
  • 1
  • 1
jlarks32
  • 931
  • 8
  • 20

0 Answers0