標籤:

[Tensorflow]-[error]讀取pb文件時的error

ValueError: graph_def is invalid at node encoder/0/bn/ExponentialMovingAverage/AssignMovingAvg: Input tensor encoder/0/bn/encoder/0/bn/moments/moments_1/mean/ExponentialMovingAverage:0 Cannot convert a tensor of type float32 to an input of type float32_ref.

尚未解決


ValueError: graph_def is invalid at node uconv1/BatchNorm/cond/AssignMovingAvg/Switch: Input tensor conv1/BatchNorm/cond/pred_id/read:0 not found in graph_def..

報錯代碼:

# read graph definitionf = tf.python.platform.gfile.FastGFile(model_path)gd = graph_def = tf.GraphDef()graph_def.ParseFromString(f.read())# fix nodesfor node in graph_def.node: if node.op == RefSwitch: node.op = Switch for index in xrange(len(node.input)): node.input[index] = node.input[index] + /read elif node.op == AssignSub: node.op = Sub if use_locking in node.attr: del node.attr[use_locking]# import graph into sessiontf.import_graph_def(graph_def, name=)

修正後:

# read graph definitionf = tf.python.platform.gfile.FastGFile(model_path)gd = graph_def = tf.GraphDef()graph_def.ParseFromString(f.read())# fix nodesfor node in graph_def.node: if node.op == RefSwitch: node.op = Switch for index in xrange(len(node.input)): if moving_ in node.input[index]: node.input[index] = node.input[index] + /read elif node.op == AssignSub: node.op = Sub if use_locking in node.attr: del node.attr[use_locking]# import graph into sessiontf.import_graph_def(graph_def, name=)#Ive only changed the inputs related to the "moving_variance" and "moving_mean".

參考網址:

Unable to import frozen graph with batchnorm · Issue #3628 · tensorflow/tensorflowgithub.com圖標
推薦閱讀:

譯文 | 簡明 TensorFlow 教程:混合模型
ubuntu16.04 tensorflow cuda8.0 cudnn5.1
學習筆記TF033:實現ResNet
如何使用最流行框架Tensorflow進行時序預測和時間序列分析
對比深度學習十大框架:TensorFlow最流行但並不是最好

TAG:TensorFlow |