paddleslim 知识蒸馏demo的问题
Created by: lastrei
在进行到查看Variables这一步后,进行合并蒸馏loss,这时候报错 : var depthwise_conv2d_11.tmp_0 not in this block 查看Variables发现 student的Variables里并没有depthwise_conv2d_11.tmp_0
通过观察发现 student模型中的depthwise_conv2d_24.tmp_0与teacher中的teacher_bn5c_branch2b.output.1.tmp_3的尺寸一致都是(-1, 512, 1, 1)
所以把demo中的合并蒸馏loss改成了
data_name_map = {'image': 'image'}
main = slim.dist.merge(teacher_program, student_program, data_name_map, fluid.CPUPlace())
with fluid.program_guard(student_program, student_startup):
l2_loss = slim.dist.l2_loss('teacher_bn5c_branch2b.output.1.tmp_3', 'depthwise_conv2d_24.tmp_0', student_program)
loss = l2_loss + avg_cost
opt = fluid.optimizer.Momentum(0.01, 0.9)
opt.minimize(loss)
exe.run(student_startup)
但是最后一步训练的时候又报这个错误
InvalidArgumentError: ShapeError: the shape of scale must equal to [32]But received: the shape of scale is [64]
[Hint: Expected scale_dim[0] == C, but received scale_dim[0]:64 != C:32.] at (/paddle/paddle/fluid/operators/batch_norm_op.cc:116)
[operator < batch_norm > error]
麻烦请看一下,执行是在aistudio平台,麻烦看一下谢谢