Last active
July 20, 2019 02:35
-
-
Save Quorafind/b06d3d15b6636dc57e5216349635813c to your computer and use it in GitHub Desktop.
加载.pb文件
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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