import tensorflow as tf with tf.Session() as sess: with open('./quantized_model.pb', 'rb') as f: graph_def = tf.GraphDef() graph_def.ParseFromString(f.read()) print graph_def output = tf.import_graph_def(graph_def, return_elements=['out:0']) print(sess.run(output))
复制代码 效果:
复制代码
node { name: "FullyConnected/BiasAdd" op: "BiasAdd" input: "FullyConnected/MatMul" input: "FullyConnected/b/read" attr { key: "T" value { type: DT_FLOAT } } attr { key: "data_format" value { s: "NHWC" } } } node { name: "FullyConnected/Softmax" op: "Softmax" input: "FullyConnected/BiasAdd" attr { key: "T" value { type: DT_FLOAT } } } library { }