在训练我的模型将近两天后,生成了以下三个文件:
best_model.ckpt.data-00000-of-00001best_model.ckpt.indexbest_model.ckpt.meta
其中best_model
是我的模型名称。当我尝试使用以下命令导入我的模型时
with tf.Session() as sess: saver = tf.train.import_meta_graph('best_model.ckpt.meta') saver.restore(sess, "best_model.ckpt")
我得到了以下错误
Traceback (most recent call last):File "<stdin>", line 2, in <module>File "/home/shreyash/.local/lib/python2.7/site-packages/tensorflow/python/training/saver.py", line 1577, in import_meta_graph **kwargs) File "/home/shreyash/.local/lib/python2.7/site-packages/tensorflow/python/framework/meta_graph.py", line 498, in import_scoped_meta_graph producer_op_list=producer_op_list)File "/home/shreyash/.local/lib/python2.7/site-packages/tensorflow/python/framework/importer.py", line 259, in import_graph_def raise ValueError('No op named %s in defined operations.' % node.op)ValueError: No op named attn_add_fun_f32f32f32 in defined operations.
如何修复这个问题?
我参考了这个帖子:TensorFlow, why there are 3 files after saving the model?
- 已使用pip安装的TensorFlow版本1.0.0
- Linux版本16.04
- Python 2.7
回答:
导入器无法在你的图中找到一个非常特定的函数,即attn_add_fun_f32f32f32
,这可能是注意力函数之一。
你可能遇到了这个问题。然而,他们说这个问题在TensorFlow 1.0中已被解决。请再次确认已安装的TensorFlow版本是否包含attention_decoder_fn.py
(或者,如果你使用的是其他库,请检查它是否存在)。
如果它存在,以下是你的选择: