4

我正在努力实施 Hinton 的知识蒸馏论文。第一步是存储温度较高的“笨重模型”的软目标(即我不需要训练网络,只需要对每个图像进行前向传递并存储具有温度的软目标T)。
有没有办法获得 Alexnet 或 googlenet 软目标的输出但温度不同?
我需要修改 soft-max pi= exp(zi/T)/sum(exp(zi/T)
需要用一个温度来划分最终全连接层的输出T。我只需要这个来进行前传(而不是训练)。

4

1 回答 1

3

我相信有三种选择可以解决这个问题

1.Softmax使用温度参数实现您自己的层。softmax_layer.cpp修改代码以考虑“温度”应该是相当直接的T。您可能还需要调整caffe.proto以允许Softmax使用额外参数解析层。

2.将该层实现为python层

3.如果你只需要一个前向传递,即“提取特征”,那么你可以简单地将softmax层之前的层的“顶部”作为特征输出,并在caffe之外进行softmax。

4.您可以在Scale顶层之前添加Softmax层:

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"
}
于 2015-11-10T07:14:18.400 回答