我一直在尝试使用freeze_graph函数来获得模型+权重/偏差,但在这个过程中,我发现我的初始网络似乎没有任何变量,尽管能够正确地对图像进行分类。我的代码如下:#!/usr/bin/python
import tensorflow as tf
import numpy as np
def outputCheckpoint(sess):
with sess.as_default():
print("Saving to checkpoint")
saver = tf.train.Saver()
# Fails on this line: 'ValueError: No variables to save'
saver.save(sess, '/path/to/tensorflow/graph_saver/save_checkpoint')
def main():
with tf.device('/cpu:0'):
with open("tensorflow_inception_graph.pb", mode='rb') as f:
fileContent = f.read()
graph_def = tf.GraphDef()
graph_def.ParseFromString(fileContent)
images = tf.placeholder("float", [ None, 299, 299, 3])
tf.import_graph_def(graph_def, input_map={ "Mul": images })
print "graph