简体   繁体   中英

Unable to load a pretrained model

After training my model for almost 2 days 3 files were generated:

best_model.ckpt.data-00000-of-00001
best_model.ckpt.index
best_model.ckpt.meta

where best_model is my model name. 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 version 1.0.0 installed using pip
  • Linux version 16.04
  • python 2.7

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 .

Probably you've stepped into this issue . However, they say it's bundled in 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).

If it's there, here are your options:

  • Rename this operation , if possible. You might want to read this discussion for workarounds.
  • Duplicate your graph definition, so that you won't have to call import_meta_graph , but restore the model into the current graph.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM