CNTK icon indicating copy to clipboard operation
CNTK copied to clipboard

How to determine the parameters for AlexNet

Open rold2007 opened this issue 10 years ago • 2 comments

I am trying to modify AlexNet to support a smaller input image size. I wonder if I should also modify the following parameters, and if so how should I determine the values to use. Seeing values such as 2.07 I guess that this was not chosen by a human.

Parameters: conv1WScale = 0.95 conv1BValue = 0 conv2WScale = 2 conv2BValue = 1 conv3WScale = 2.07 conv3BValue = 0 conv4WScale = 2.9 conv4BValue = 1 conv5WScale = 2.4 conv5BValue = 1 fc1WScale = 6.4 fc1BValue = 1 fc2WScale = 3.2 fc2BValue = 1 fc3WScale = 3.2 fc3BValue = 1

rold2007 avatar Apr 22 '16 08:04 rold2007

Hi David, These values were chosen by a human and that human was me :) Sadly, that human also failed to document the process of obtaining these magic values - a mistake that I will try to correct in this reply and then in samples/Wiki. When you use LearnableParameter with normal distribution for initial values, CNTK initializes it with 0 mean and standard deviation of: 0.2 * initValueScale / sqrt(NumColumns) - this is described in our book, but not yet in the Wiki. In the original Krizhevsky paper they initialized all weights using stdev of 0.01. So to come up with correct values for each layer in case of CNTK, you would need to use the following formula: initValueScale = StdDev * sqrt(NumColumns) / 0.2. So in case of the first convo layer (conv1) we get: 0.01*sqrt(11*11*3)/0.2 == 0.952... The problem, of course, is that you have to compute these values for each layer separately. Now, initializing weights of a deep neural network with fixed stddev is now considered a technique from bygone times. One of the most popular modern techniques is due to paper by our own MSRA. In short, this technique uses the following formula for computing stddev of initial weights for a convolutional layer: stddev = sqrt(2 / n) where n is the size of the kernel which happens to be number of columns in CNTK. This technique is used in other CNTK samples like ResNet where there is just one value for all convo layers which represents the scaling factor: sqrt(2)/0.2 = 7.07 I would probably recommend using the newer technique though I haven’t tried it myself on AlexNet. Hope this helps.

Alexey-Kamenev avatar Apr 22 '16 22:04 Alexey-Kamenev

Thanks for the detailed answer !

rold2007 avatar Apr 25 '16 00:04 rold2007