stuarteiffert / RNN-for-Human-Activity-Recognition-using-2D-Pose-Input

Activity Recognition from 2D pose using an LSTM RNN
291 stars 77 forks source link

Restoring and predicting on NEW data in new tf.Session() #32

Closed zlg9folira closed 3 years ago

zlg9folira commented 3 years ago

Thank you @stuarteiffert for the great work. I trained this model on my data (34 features instead of 38) and saved the model ckpt. I am struggling to restore this model and do prediction on a different machine and within different session.

       sess = tf.Session()
       saver = tf.train.import_meta_graph(`save_path/model.ckpt.meta')
       saver.restore(sess, tf.latest_checkpoint('save_path/'))

       # ------------
       # what am I missing here ?
       #-------------

       X_val = load_X('X_val.txt')
       preds = sess.run([pred], feed_dict={x: X_val})

Since I have not constructed pred it throws name 'pred' is not defined. Since, this script seats in a new code where there is no re-training process, I need to make sure the first argument in sess.run() is valid. Obviously, I am missing few lines which I need help. Thank you

zlg9folira commented 3 years ago

The issue got solved. For those who ran into the same issue, this is a good reference: https://stackoverflow.com/a/49592879/12820646. In particular in this example,pred must be extracted from the frozen graph, the same way x is extracted.