The class implements a layer that performs batch normalization using the following formula:
bn(x)[i][j] = ((x[i][j] - mean[j]) / sqrt(var[j])) * gamma[j] + beta[j]where:
gammaandbetaare the trainable parametersmeanandvardepend on whether the layer is being trained:- If the layer is being trained,
mean[j]andvar[j]are the mean value and the variance ofxdata withjcoordinate across alli. - If the layer is not being trained,
mean[j]andvar[j]are the exponential moving mean and the unbiased variance estimate calculated during training.
- If the layer is being trained,
void SetChannelBased( bool isChannelBased );Turns on and off channel-based statistics.
If this mode is on, mean, var, gamma, and beta in the formula will be vectors of the input Channels length. The i coordinate will iterate over all values from 0 to BatchLength * BatchWidth * ListSize * Height * Width * Depth - 1.
If this mode is off, the mean, var, gamma, and beta vectors will have the Height * Width * Depth * Channels length. The i coordinate will iterate over all values from 0 to BatchLength * BatchWidth * ListSize - 1.
By default the channelwise mode is on.
SetSlowConvergenceRate( float rate );Sets the coefficient for calculating the exponential moving mean and variance.
CPtr<CDnnBlob> GetFinalParams();Gets the final values of the parameters. They are returned as a blob of the dimensions:
BatchLengthis equal to1BatchWidthis equal to2ListSizeis equal to1Heightis equal to1whenIsChannelBased(), the inputHeightotherwiseWidthis equal to1whenIsChannelBased(), the inputWidthotherwiseDepthis equal to1whenIsChannelBased(), the inputDepthotherwiseChannelsis equal to1
The first object of the blob (BatchWidth coordinate is equal to 0) contains the coefficients gamma[j] / sqrt(var[j]).
The second object of the blob (BatchWidth coordinate is equal to 1) contains the terms beta[j] - mean[j] * gamma[j] / sqrt(var[j]).
The batch normalization formula can then be rewritten as bn(x)[i][j] = x[i][j] * finalParams[0][j] + finalParams[1][j].
The single input accepts a blob of any size.
The single output contains a blob with the results of batch normalization.