I am working on implementing Hinton's Knowledge distillation paper. The first step is to store the soft targets of a "cumbersome model" with a higher temperature (i.e. I don't need to train the network, just need to do forward pass per image and store the soft targets with a temperature T
).
Is there a way I can get the output of Alexnet or googlenet soft targets but with a different temperature?
I need to modify the soft-max with pi= exp(zi/T)/sum(exp(zi/T)
.
Need to divide the outputs of the final fully connected layer with a temperature T
. I only need this for the forward pass (not for training).
相关问题
- How to use Reshape keras layer with two None dimen
- neural network does not learn (loss stays the same
- Trying to understand Pytorch's implementation
- Convolutional Neural Network seems to be randomly
- How to convert Onnx model (.onnx) to Tensorflow (.
相关文章
- how to flatten input in `nn.Sequential` in Pytorch
- How to downgrade to cuda 10.0 in arch linux?
- Looping through training data in Neural Networks B
- Why does this Keras model require over 6GB of memo
- How to measure overfitting when train and validati
- TensorFlow Eager Mode: How to restore a model from
- Create image of Neural Network structure
- loss, val_loss, acc and val_acc do not update at a
I believe there are three options to solve this problem
1. Implement your own
Softmax
layer with a temperature parameter. It should be quite straight forward to modify the code ofsoftmax_layer.cpp
to take into account a "temperature"T
. You might need to tweak thecaffe.proto
as well to allow for parsingSoftmax
layer with an extra parameter.2. Implement the layer as a python layer.
3. If you only need a forward pass, i.e. "extracting features", then you can simply output as features the "top" of the layer before the softmax layer and do the softmax with temperature outside caffe altogether.
4. You can add
Scale
layer before the topSoftmax
layer: