[英]Unable to load a pretrained model
After training my model for almost 2 days 3 files were generated: 在对我的模型进行了将近2天的训练之后,生成了3个文件:
best_model.ckpt.data-00000-of-00001
best_model.ckpt.index
best_model.ckpt.meta
where best_model
is my model name. 其中,
best_model
是我的模型名称。 When I try to import my model using the following command 当我尝试使用以下命令导入模型时
with tf.Session() as sess:
saver = tf.train.import_meta_graph('best_model.ckpt.meta')
saver.restore(sess, "best_model.ckpt")
I get the following error 我收到以下错误
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.
How to fix this? 如何解决这个问题?
I have referred this post: TensorFlow, why there are 3 files after saving the model? 我已经提到了这篇文章: TensorFlow,为什么保存模型后会有3个文件?
The importer can't find a very specific function in your graph, namely attn_add_fun_f32f32f32
, which is likely to be one of attention functions . 导入程序无法在您的图形中找到非常具体的功能,即
attn_add_fun_f32f32f32
,它很可能是关注功能之一 。
Probably you've stepped into this issue . 可能您已涉足此问题 。 However, they say it's bundled in tensorflow 1.0.
但是,他们说它捆绑在tensorflow 1.0中。 Double check that installed tensorflow version contains
attention_decoder_fn.py
(or, if you are using another library, check that it's there). 所安装tensorflow版本仔细检查包含
attention_decoder_fn.py
(或者,如果你使用的是其他库,检查它的存在)。
If it's there, here are your options: 如果有,这里是您的选择:
import_meta_graph
, but restore the model into the current graph. import_meta_graph
,而是将模型还原到当前图中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.