用于评估经过预训练的模型(deepLab),我使用了Frozen_graph建立了模型。但是我无法加载权重并正确初始化模型。 我的火车目录中有一些文件,例如(frozen.Pb-* .meta-ckpt),但我不能使用它们
这是我的代码
class DeepLabModel2(object):
INPUT_TENSOR_NAME = 'ImageTensor:0'
OUTPUT_TENSOR_NAME = 'semantic:0' #'ArgMax:0'#'SemanticPredictions:0'
INPUT_SIZE = 513
num_classes = 21;
FROZEN_GRAPH_NAME = 'frozen_inference_graph'
def __init__(self, tarball_path):
self.graph = tf.Graph();
with self.graph.as_default():
model_options = common.ModelOptions(
outputs_to_num_classes={common.OUTPUT_TYPE: self.num_classes},
crop_size=FLAGS.eval_crop_size,
atrous_rates=FLAGS.atrous_rates,
output_stride=FLAGS.output_stride)
tf.logging.info('Performing single-scale test.')
samples = tf.placeholder(tf.float32, shape=(None, self.INPUT_SIZE, self.INPUT_SIZE, 3), name='ImageTensor')
self.predictions = model.predict_labels(samples, model_options,
image_pyramid=FLAGS.image_pyramid)
#predictions2 = predictions[common.OUTPUT_TYPE]
#predictions = tf.reshape(predictions, shape=[-1])
self.sess = tf.Session(graph=self.graph)
tf.global_variables_initializer().run(session=self.sess);
我使用以下代码恢复体重
saver = tf.train.Saver(variables_to_restore)
with tf.Session() as self.sess:
saver.restore(self.sess, model_path)
并出现错误:ValueError:没有要保存的变量