简体   繁体   中英

Loading a saved RNN in Tensorflow

I was just playing around this tutorial from TensorFlow.

A complete step by step guide is provided here .

And the source code is given here .

Now I want to do something more. I want to save the trained RNN and load it in another python script, so that I can give input to the RNN and it will generate the next probable word.

To save the model I ran the command:

cd models/tutorials/rnn/ptb
python ptb_word_lm.py --data_path=/tmp/simple-examples/data/ --model=small --save_path=~/Desktop/SavedRNN/

Then I got a checkpoint file with these entries:

model_checkpoint_path: "/home/piyush/Documents/college courses/year 3/sem 6/Information Retrieval/project2/-30199"
all_model_checkpoint_paths: "/home/piyush/Documents/college courses/year 3/sem 6/Information Retrieval/project2/model.ckpt-24745"
all_model_checkpoint_paths: "/home/piyush/Documents/college courses/year 3/sem 6/Information Retrieval/project2/model.ckpt-26220"
all_model_checkpoint_paths: "/home/piyush/Documents/college courses/year 3/sem 6/Information Retrieval/project2/model.ckpt-27762"
all_model_checkpoint_paths: "/home/piyush/Documents/college courses/year 3/sem 6/Information Retrieval/project2/model.ckpt-29237"
all_model_checkpoint_paths: "/home/piyush/Documents/college courses/year 3/sem 6/Information Retrieval/project2/-30199" 

And I got 9 files of 3 types

models.ckpt.<some-number>.data-00000-of-00001
models.ckpt.<some-number>.meta
models.ckpt.<some-number>.index

Now I am unable to find any documentation to load this model in tensorflow. All the examples I came across were just using the tf.saver with only one checkpoint.

I am guessing, it has something to do with supervisor . But I am not sure.

Now the missing steps I want to perform is:

  1. Load the saved model in TensorFlow (python)
  2. Run the model with my own input.

<some_number>模型,请在加载模型时将检查点路径最多传递到<some_number>到Saver(这应该在构建图形之后,重新使用提供的示例中的代码)。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM