问题记录:恢复某些层参数,遇到NotFoundError: Key conv2d_168/bias not found in checkpoint

问题描述:对网络结构做了些修改,导入已训练的参数,出现NotFoundError

相关程序:

#State where your log file is at.
log_dir = './log2'

#State where your checkpoint file is 
checkpoint_file = './log/model.ckpt-300068'

#Define the scopes that you want to exclude for restoration
exclude = ['conv_0','conv_1','conv_2']
variables_to_restore = slim.get_variables_to_restore(exclude=exclude)

#Now we create a saver function that actually restores the variables from a checkpoint file in a sess
saver = tf.train.Saver(variables_to_restore)
def restore_fn(sess):
	return saver.restore(sess,checkpoint_file)
sv = tf.train.Supervisor(logdir = log_dir,summary_op = None, init_fn = restore_fn) 

报错:

问题记录:恢复某些层参数,遇到NotFoundError: Key conv2d_168/bias not found in checkpoint_第1张图片

问题原因:没有导入参数

问题语句:

exclude = ['conv_0','conv_1','conv_2']
variables_to_restore = slim.get_variables_to_restore(exclude=exclude)

解决措施:

include = ['dense_1','dense_2','dense_3']
variables_to_restore = slim.get_variables_to_restore(include=include)



你可能感兴趣的:(网络程序)