我遇到Tensorflow恢复模型的问题。我有一个脚本,根据一组训练文件生成几个模型。这些模型使用
创建自己的变量scopingstf.variable_scope(myPrefix).
训练结束后,我可以使用
恢复模型tf.train.Saver(model_vars).restore(sess, model)
将model_vars计算为
all_vars = tf.all_variables()
model_vars=[k for k in all_vars if k.name.startswith(myPrefix)]
虽然模型确实似乎加载,但运行它们会产生占位符错误(参见下文,85314_tr_10
是我的前缀)。
我很确定我不会跳过任何占位符。该模型只有两个(x
和y
),这些是我制作的eval
来电使用的:
predictions = sess.run(pred, feed_dict={x: test_data, y:test_labels})
这是错误跟踪:
W tensorflow/core/common_runtime/executor.cc:1076] 0x2ea0e60 Compute status: Invalid argument: You must feed a value for placeholder tensor '85314_tr_10/Placeholder' with dtype float
[[Node: 85314_tr_10/Placeholder = Placeholder[dtype=DT_FLOAT, shape=[], _device="/job:localhost/replica:0/task:0/cpu:0"]()]]
Traceback (most recent call last):
File "../prediction/views.py", line 507, in <module>
predict("","85314","True","2015-11-12T09:08:00Z","2015-11-12T10:08:00Z")
File "../prediction/views.py", line 472, in predict
predictions= prediction.eval(feed_dict={x: test_data,y:test_labels}, session=sess)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 460, in eval
return _eval_using_default_session(self, feed_dict, self.graph, session)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2910, in _eval_using_default_session
return session.run(tensors, feed_dict)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 368, in run
results = self._do_run(target_list, unique_fetch_targets, feed_dict_string)
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/client/session.py", line 444, in _do_run
e.code)
非常感谢任何帮助!