我正在努力实现Hinton的知识蒸馏纸。第一步是存储温度较高的“烦琐模型”的软目标(即我不需要对网络进行训练,只需要对每幅图像进行前向传递,并使用温度T存储软目标)。
有什么方法可以让我得到Alexnet或googlenet的软目标的输出,但温度不同?
我需要修改软最大与pi= exp(zi/T)/sum(exp(zi/T)。
需要用温度T来划分最终完全连接层的输出。我只需要这个作为前传(而不是训练)。
发布于 2015-11-10 07:14:18
我相信解决这个问题有三种选择。
1.使用温度参数实现您自己的Softmax层。修改softmax_layer.cpp的代码以考虑到“温度”T应该是非常直接的。您可能还需要调整caffe.proto以允许使用额外的参数解析Softmax层。
2.将该层实现为python层。
3. --如果您只需要向前通过,即“提取特征”,那么您可以简单地将层的“顶部”输出到中,然后将软最大值与caffe外的温度一起完成。
4.您可以在顶级Softmax层之前添加Scale层:
layer {
type: "Scale"
name: "temperature"
bottom: "zi"
top: "zi/T"
scale_param {
filler: { type: 'constant' value: 1/T } # replace "1/T" with the actual value of 1/T.
}
param { lr_mult: 0 decay_mult: 0 } # make sure temperature is fixed
}
layer {
type: "Softmax"
name: "prob"
bottom: "zi/T"
top: "pi"
}https://stackoverflow.com/questions/33622333
复制相似问题