2017-10-04 152 views
1

訓練我的模型,近2天生成3個文件後:無法加載預訓練模式

best_model.ckpt.data-00000-of-00001 
best_model.ckpt.index 
best_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?

  • Tensorflow版本1.0.0安裝使用PIP
  • Linux版本的16.04
  • 蟒蛇2.7

回答

1

進口商無法找到一個很你的圖中的特定函數,即attn_add_fun_f32f32f32,很可能是one of attention functions。可能你已經步入this issue。但是,他們說它捆綁在tensorflow 1.0中。仔細檢查安裝的tensorflow版本是否包含attention_decoder_fn.py(或者,如果您正在使用其他庫,請檢查它是否存在)。

如果它的存在,您有以下選項:

  • Rename this operation,如果可能的話。您可能需要閱讀this discussion的解決方法。
  • 複製您的圖形定義,以便您不必調用import_meta_graph,但可將模型恢復到當前圖形中。