我试图通过引用下面的文档重新训练Inception的新类别的最后一层
当我使用新的图像收集和完成培训,我使用以下推荐测试,但失败了!
(tensorflow13) C:\Users\James\Tensorflow\model-retrain\tensorflow-for-poets-2\scripts>python .\label_image.py --image c:\Users\James\Tensorflow\sample_img\Panda001.jpg --graph c:\Users\James\Tensorflow\model-retrain\tensorflow-for-poets-2\scripts\retrained_graph.pb --labels C:\Users\James\Tensorflow\model-retrain\tensorflow-for-poets-2\scripts\retrained_labels.txt错误信息:
2017-09-01 09:27:46.902115: I C:\tf_jenkins\home\workspace\nightly-win\M\windows\PY\36\tensorflow\core\platform\cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
Traceback (most recent call last):
File ".\label_image.py", line 120, in <module>
input_operation = graph.get_operation_by_name(input_name);
File "C:\Users\James\AppData\Local\conda\conda\envs\tensorflow13\lib\site-packages\tensorflow\python\framework\ops.py", line 3225, in get_operation_by_name
return self.as_graph_element(name, allow_tensor=False, allow_operation=True)
File "C:\Users\James\AppData\Local\conda\conda\envs\tensorflow13\lib\site-packages\tensorflow\python\framework\ops.py", line 3097, in as_graph_element
return self._as_graph_element_locked(obj, allow_tensor, allow_operation)
File "C:\Users\James\AppData\Local\conda\conda\envs\tensorflow13\lib\site-packages\tensorflow\python\framework\ops.py", line 3157, in _as_graph_element_locked
"graph." % repr(name))
KeyError: "The name 'import/input' refers to an Operation not in the graph."有人也有同样的问题吗?
发布于 2017-09-05 15:47:55
由于某种原因,retrained_graph.pb没有脚本所期望的输入。它的构建可能与教程所期望的略有不同(特别是关于元图是如何导入的)。
发布于 2019-01-27 10:57:16
这里的问题是您的输入/输出可能是错误的,脚本使用的是:
input_name = "file_reader"
output_name = "normalized"如果您训练了这个模型,您可能需要找到您的输入/输出,因为它们可能是不同的。
我不知道找出这个问题的最佳方法,但是这段代码已经帮了我一个忙:
import tensorflow as tf
frozen='/tensorflow/mobilenets/mobilenet_v1_1.0_224.pb'
gf = tf.GraphDef()
gf.ParseFromString(open(frozen,'rb').read())
[n.name + '=>' + n.op for n in gf.node if n.op in ( 'Softmax','Placeholder')]
[n.name + '=>' + n.op for n in gf.node if n.op in ( 'Softmax','Mul')]https://stackoverflow.com/questions/45992351
复制相似问题