tensorflow保存模型参数文件pb查看

查看pb文件的节点参数:
with tf.Session() as sess:
with open(model, ‘rb’) as model_file:
graph_def = tf.GraphDef()
graph_def.ParseFromString(model_file.read())
print(graph_def)

模型导入出现的异常问题:
由batch normalzition,或者残差网络层导致的问题可采用下方的方法尝试~
#下方一段代码在有batch normalzition,或者残差网络层运用在 restore或者tf.import_graph_def()之前

        for node in output_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']

你可能感兴趣的:(tensorflow)