我正在为我的 Tensorflow 模型而苦苦挣扎。我已经使用tf.PaddingFIFOQueue对其进行了训练,然后我主要使用了本教程:https ://blog.metaflow.fr/tensorflow-how-to-freeze-a-model-and-serve-it-with-a-python- api-d4f3596b3adc#.dykqbzqek,用于冻结图形及其变量,然后将其加载到库中以推断模型。
我的问题是我真的不知道如何运行模型来进行预测,一旦它被加载。在仅占位符作为输入的情况下,只需要获取输入和输出变量,然后运行模型:
# We load the graph
graph_path = ...
graph = load_graph(graph_path)
# We launch a Session
with tf.Session(graph=graph) as sess:
# Note: we didn't initialize/restore anything, everything is stored in the graph_def
y_out = sess.run(y, feed_dict={
x: [[3, 5, 7, 4, 5, 1, 1, 1, 1, 1]] # < 45
})
print(y_out) # [[ False ]] Yay, it works!
在这个例子中,它看起来真的很简单,但是对于带有输入管道的用例,我并没有真正弄清楚如何让它工作。我什至没有找到任何相关的东西。我有人可以给我一个提示,应该如何做到这一点,或者人们通常如何在生产中使用 Tensorflow 会非常有帮助。