CNTK icon indicating copy to clipboard operation
CNTK copied to clipboard

Different Learning rates in each layer

Open navidnadery opened this issue 10 years ago • 4 comments

Hello I have 2 Convolution Layers and 2 hidden layers and also one output layer. I want to set the learning rate of different layers differently. For example i want LR=0.1 for the first Convolution layer, LR=0.05 for the second Convolution layer and the rest LR=0.003. Now i use this way : learningRatesPerMB = 0.001

Thanks in advance for @dongyu888 and @frankseide

navidnadery avatar Aug 11 '16 20:08 navidnadery

This is a little involved. Every Parameter() has an optional parameter learningRateMultiplier which defaults to 1. You can set it to 0.5 for all weights in the second layer, and to 0.03 for the rest.

frankseide avatar Aug 11 '16 22:08 frankseide

However, personally I would try to avoid this, and try different solutions. Are you using BatchNormalization? There is also a simplified version that consists of multiplying a layer's output with a constant scalar, which may achieve the same. And if you make that scalar learnable, you could get a learning speed-up. E.g. in our seq-2-seq example, we use this form

yourLayerOutput1 = BS.Parameters.Stabilize (yourLayerOutput)

which is defined as follows in CNTK.core.bs:

Stabilize (x, enabled=true) = if enabled then StabilizeElements (x, inputDim=1, enabled=true) else x

StabilizeElements (x, inputDim=x.dim, enabled=true) =
    if enabled
    then [
        # sharpened Softplus: 1/f ln(1+e^{f*beta})
        # this behaves linear for weights around 1, yet guarantees positiveness
        f = ConstantTensor (4, (1))
        fInv = Reciprocal (f)
        beta = fInv .* Log (Constants.One + Exp (f .* ParameterTensor ((inputDim), initValue=0.99537863/* 1/f*ln (e^f-1) */))) # init value is 1

        result = beta .* x
    ].result
    else x

frankseide avatar Aug 11 '16 22:08 frankseide

@frankseide Great answer. Is their a paper that describes the stabilization trick or is it common neural network knowledge?

e-thereal avatar Aug 12 '16 09:08 e-thereal

Thank you @frankseide , i will try your recommendation. And i don't use BatchNormalization. Does it make any difference?

navidnadery avatar Aug 12 '16 09:08 navidnadery