Skip to content

Instantly share code, notes, and snippets.

@Quorafind
Last active July 20, 2019 02:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Quorafind/b06d3d15b6636dc57e5216349635813c to your computer and use it in GitHub Desktop.
Save Quorafind/b06d3d15b6636dc57e5216349635813c to your computer and use it in GitHub Desktop.
加载.pb文件
def load_pb(path_to_pb):
with tf.gfile.GFile(path_to_pb, "rb") as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
with tf.Graph().as_default() as graph:
tf.import_graph_def(graph_def, name='')
return graph
#你可以检索感兴趣的张量
input = graph.get_tensor_by_name('input:0')
output = graph.get_tensor_by_name('output:0')
#或者
sess.run(output, feed_dict={input: some_data})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment