leovandriel / caffe2_cpp_tutorial

C++ transcripts of the Caffe2 Python tutorials and other C++ example code
BSD 2-Clause "Simplified" License
432 stars 94 forks source link

Batch normalization #56

Open edubois opened 6 years ago

edubois commented 6 years ago

I'm reading the example provided here, trying to adapt what I read to another net: https://github.com/leonardvandriel/caffe2_cpp_tutorial/blob/master/include/caffe2/zoo/resnet.h

I just wanted to know, when doing a batch normalization, I see that you are adding some inputs: predict.AddInput(p + "_s"); predict.AddInput(p + "_b"); predict.AddInput(p + "_rm"); predict.AddInput(p + "_riv");

I guess those are the scale, bias, mean and variance values of the input layer of the BN. My question is: are those holders linked/computed by caffe2 or shall I link them / compute them in some way? I'm not sure why we need to add inputs.

leovandriel commented 6 years ago

Hi, these parameters are trained by the SpatialBN operator provided bool train is set to true, and should not require any intervention from your side.