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

当尝试加载已训练的模型参数并调整网络结构后,遇到'Key conv2d_168/bias not found in checkpoint'的错误。问题源于缺少特定层的权重导入。解决方案在于确保正确导入所有必需的模型参数。
摘要由CSDN通过智能技术生成

问题描述:对网络结构做了些修改,导入已训练的参数,出现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) 

报错:

问题原因:没有导入参数

问题语句:

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值