更新时间:2023-12-02 21:43:52
使用此代码:这对我有用:
Use this code: This works for me:
import tensorflow as tf
from tensorflow.python.platform import gfile
with tf.Session() as sess:
model_filename ='YouGraphNameWithPath.pb'
with gfile.FastGFile(model_filename, 'rb') as f:
graph_def = tf.GraphDef()
graph_def.ParseFromString(f.read())
g_in = tf.import_graph_def(graph_def)
LOGDIR='PathWhereSummaryWillBeSaved'
train_writer = tf.summary.FileWriter(LOGDIR)
train_writer.add_graph(sess.graph)