【问题标题】:Use model to predict the next word using Tensorflow使用模型预测下一个词使用Tensorflow
【发布时间】:2017-03-05 21:37:54
【问题描述】:

我按照tutorial 训练了一个“循环神经网络”并得到了一个模型:

model/
model/model.ckpt-72985.data-00000-of-00001
model/model.ckpt-72883.meta
model/model.ckpt-72793.meta
model/model.ckpt-72985.meta
model/model.ckpt-72793.index
model/model.ckpt-72971.data-00000-of-00001
model/events.out.tfevents.1488038213.mymachine
model/model.ckpt-72883.index
model/model.ckpt-72985.index
model/graph.pbtxt
model/model.ckpt-72883.data-00000-of-00001
model/model.ckpt-72793.data-00000-of-00001
model/model.ckpt-72971.index
model/model.ckpt-72971.meta
model/checkpoint

现在,我想用这个模型来预测程序中的下一个单词,我该怎么做?

我想用nextWord("What is next word?")之类的函数来返回预测词。

【问题讨论】:

    标签: tensorflow tensorflow-serving


    【解决方案1】:

    您想使用tf.train.Saver

    saved_model = tf.train.get_checkpoint_state('./model/') #or your model path
    saver = tf.train.Saver()
    
    with tf.Session() as sess:
        saver.restore(sess, saved_model.model_checkpoint_path)
    

    您可能还想看看this example

    【讨论】:

    • 我没有带有 ckpt 扩展名的文件。
    猜你喜欢
    • 2016-02-19
    • 2016-07-17
    • 2021-05-17
    • 2016-02-16
    • 2019-06-04
    • 2018-01-16
    • 1970-01-01
    • 2018-06-12
    • 2020-01-28
    相关资源
    最近更新 更多