CNTK icon indicating copy to clipboard operation
CNTK copied to clipboard

How to lower the temperatur parameter during training?

Open e-thereal opened this issue 10 years ago • 4 comments

This post (https://github.com/Microsoft/CNTK/wiki/Express-a-softmax-with-a-temperature-parameter)shows how to express a softmax with temperatur parameter in CNTK. Is there a way to decrease the temperatur over training time, i.e., with increasing number of epochs, similar to how the learning rate can be adjusted over training time?

e-thereal avatar Oct 20 '16 13:10 e-thereal

I think the best way is to do it through a ndl file:

for example if a simple softmax layer is defined by:

SMFF(x, y, z, labels)
{
    FF = FF(x, y, z)
    SM = CrossEntropyWithSoftmax(labels, FF)
}

you can reduce softmax temperature by multiplying/dividing by a T factor, as bellow:

SMFF(x, y, z, T, labels)
{
    FF = FF(x, y, z)
    FF = FF .* T
    SM = CrossEntropyWithSoftmax(labels, FF)
}

Thank you for your answer. Is there a way to also lower the T factor with each epoch? When I read your example correctly, the same temperatur (T factor) will be used for each epoch.

e-thereal avatar Oct 21 '16 08:10 e-thereal

I don't know a straight way for doing that. You can achieve it by divide training phase into chunks each have an specific temperature. However this is not a good and reasonable solution and I'm curious to know better solutions...

Thank you for your suggestion. I think that approach can be reasonable for small numbers of different temperatures.

e-thereal avatar Oct 24 '16 07:10 e-thereal