{"id":111,"date":"2019-11-27T17:26:02","date_gmt":"2019-11-27T09:26:02","guid":{"rendered":"http:\/\/8.154.33.202\/?p=111"},"modified":"2019-11-27T17:26:02","modified_gmt":"2019-11-27T09:26:02","slug":"tensorflow-%e5%af%bc%e5%85%a5pb%e6%a8%a1%e5%9e%8b%e8%bf%9b%e8%a1%8c%e5%89%8d%e5%90%91%e6%8e%a8%e5%af%bc","status":"publish","type":"post","link":"http:\/\/8.154.33.202\/?p=111","title":{"rendered":"tensorflow \u5bfc\u5165pb\u6a21\u578b\u8fdb\u884c\u524d\u5411\u63a8\u5bfc"},"content":{"rendered":"\n<p>tensorflow\u4e00\u822c\u4f7f\u7528pb\u6587\u4ef6\u8fdb\u884c\u524d\u5411\u63a8\u5bfc\uff08\u5728\u975e\u90e8\u7f72\u73af\u5883\u4f7f\u7528ckpt\u4e5f\u53ef\u4ee5\uff09\u8f7d\u5165pb\u6587\u4ef6\u5230\u56fe\u7684\u51fd\u6570<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><strong>def <\/strong>load_pb_to_graph(sess, pb_file):<br>    <strong>with <\/strong>tf.gfile.FastGFile(pb_file, <strong>\"rb\"<\/strong>) <strong>as <\/strong>f:<br>        graph_def = tf.GraphDef()<br>        graph_def.ParseFromString(f.read())<br>        sess.graph.as_default()<br>        tf.import_graph_def(graph_def,name=<strong>\"\"<\/strong>)<\/pre>\n\n\n\n<p>\u5728\u4f1a\u8bdd\u4e2d\uff0c\u8c03\u7528\u8be5\u51fd\u6570\uff0c\u5e76\u6839\u636e\u540d\u79f0\u83b7\u53d6\u8f93\u5165\u548c\u8f93\u51fa\u7684tensor\uff0c\u7136\u540e\u5c31\u53ef\u4ee5sess.run\u8fdb\u884c\u524d\u5411\u63a8\u5bfc<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">load_pb_to_graph(sess, <strong>\"xxnet.pb\"<\/strong>)\ninputs = tf.get_default_graph().get_tensor_by_name(<strong>\"xxnet\/input:0\"<\/strong>)\noutputs = tf.get_default_graph().get_tensor_by_name(<strong>\"xxnet\/score:0\"<\/strong>)\nscores = sess.run([outputs], feed_dict={inputs: input_data})<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>tensorflow\u4e00\u822c\u4f7f\u7528pb\u6587\u4ef6\u8fdb\u884c\u524d\u5411\u63a8\u5bfc\uff08\u5728\u975e\u90e8\u7f72\u73af\u5883\u4f7f\u7528ckpt\u4e5f\u53ef\u4ee5\uff09\u8f7d\u5165pb\u6587\u4ef6\u5230\u56fe\u7684\u51fd\u6570 de &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/8.154.33.202\/?p=111\" class=\"more-link\">\u7ee7\u7eed\u9605\u8bfb<span class=\"screen-reader-text\">\u201ctensorflow \u5bfc\u5165pb\u6a21\u578b\u8fdb\u884c\u524d\u5411\u63a8\u5bfc\u201d<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,4],"tags":[],"class_list":["post-111","post","type-post","status-publish","format-standard","hentry","category-tensorflow","category-4"],"_links":{"self":[{"href":"http:\/\/8.154.33.202\/index.php?rest_route=\/wp\/v2\/posts\/111"}],"collection":[{"href":"http:\/\/8.154.33.202\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/8.154.33.202\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/8.154.33.202\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/8.154.33.202\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=111"}],"version-history":[{"count":1,"href":"http:\/\/8.154.33.202\/index.php?rest_route=\/wp\/v2\/posts\/111\/revisions"}],"predecessor-version":[{"id":112,"href":"http:\/\/8.154.33.202\/index.php?rest_route=\/wp\/v2\/posts\/111\/revisions\/112"}],"wp:attachment":[{"href":"http:\/\/8.154.33.202\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=111"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/8.154.33.202\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=111"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/8.154.33.202\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=111"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}