Batch normalization 2D
Hello people, Can you please tell me how to use batch normalization for 2D call ( on a 4D input ) ?
Thank you
Hi @RadjaHachilif,
You can find a simple example here. To get more info about different flavors please refer to the documentation and also batch normalization flags.
You can also look into batch normalization tests in gtest (uses C++) and in benchdnn (uses C).
Thank you for your answer, But I don't understand the difference between this example and the regular batch normalization call ( perform normalization for each channel on 3D tensors )
Sorry for delay.
Could you please elaborate on what do you mean regular batch normalization call? Intel MKL-DNN performs regular batch normalization, so what kind of difference do you expect?
I apologize, your example indeed is a 2D batch normalization over 4D inputs, I had a problem with the definition of 2d bn and i found this explanation in PyTorch documentation
Batch Normalization over a 4D input (a mini-batch of 2D inputs with additional channel dimension). The mean and standard-deviation are calculated per-dimension over the mini-batches .... Because the Batch Normalization is done over the
Cdimension, computing statistics on(N, H, W)slices, it's common terminology to call this Spatial Batch Normalization.
Thank you so much for your help.
Oh, I see.
Yes, Intel MKL-DNN's batch normalization does exactly what you found in PyTorch's documentation. In fact this algorithm should be pretty common across all major frameworks like TF, MxNet, PyTorch, and Caffe.
Close this for now. Feel free to reopen or create a new issue if you have any further questions.