我在github上找了一个代码:https://github.com/MrCPlusPlus/MobileFaceNet_Tensorflow_Pretrain/blob/master/train_nets.py
我想要尝试训练自己的数据集,我知道好像只要加几行代码就行, 但是我小白不知道怎么加,好像只要把最后一层输出层改下,其它层固定就可以了, 请大家帮忙,谢谢!
我自己瞎折腾报错 :Key Mean_1/avg not found in checkpoint, 不知道为什么??
最后一层好像是这个:
fc7/biases (DT_FLOAT) [85164]
fc7/weights (DT_FLOAT) [128,85164]
saver = tf.train.Saver(tf.trainable_variables(), max_to_keep=args.saver_maxkeep)
# init all variables
sess.run(tf.global_variables_initializer())
sess.run(tf.local_variables_initializer())
# load pretrained model
if pretrained_model:
print('Restoring pretrained model: %s' % pretrained_model)
ckpt = tf.train.get_checkpoint_state(pretrained_model)
#tf.reset_default_graph()
saver.restore(sess, ckpt.model_checkpoint_path)
print('Successfully restored!')
exclude = ['fc7']
variables_to_restore = slim.get_variables_to_restore(exclude=exclude)
init_fn = slim.assign_from_checkpoint_fn('./output/ckpt_best/MobileFaceNet_pretrain.ckpt',
variables_to_restore)
init_fn(sess)
我加的代码是这样的,但是报错lhs=[1156], rhs=[85164 也就是说原来模型的输出
和自己训练的数据集类数不同, 但是我不是已经排除模型最后一层了吗 ?
我找不到的变量是这种形式的,好像是global variables中的:
fc7/weights/ExponentialMovingAverage:0
fc7/biases/ExponentialMovingAverage:0
不同于网络结构中打出来的变量:
fc7/biases (DT_FLOAT) [85164]
fc7/weights (DT_FLOAT) [128,85164]
还有报错很多变量未初始化,但是我也添加了初始化代码啊
很郁闷. 请大家帮帮忙,谢谢了.
或者可以加我微信沟通:1886 2232 309 ,谢谢! 急 急急!