oneDNN icon indicating copy to clipboard operation
oneDNN copied to clipboard

Batch normalization

Open RadjaHachilif opened this issue 8 years ago • 2 comments

Hello, i need to use batch normalization primitive without calculating mean and variance i found this syntax but im not sure how it operates on a 4D input ( like does it calculate the mean of all values or using values within a hyperplane ) batch_normalization_forward (const primitive_desc &aprimitive_desc, const primitive::at &src, const memory &dst)

can you please explain for me how this primitive works ? Thank you

Environment

Intel MKL-DNN includes hardware-specific optimizations and may behave differently on depending on the compiler and build environment. Include the following information to help reproduce the issue:

  • CPU make and model (try lscpu; if your lscpu does not list CPU flags, try running cat /proc/cpuinfo | grep flags | sort -u)
  • OS version (uname -a)
  • Compiler version (gcc --version)
  • MKLROOT value (echo MKLROOT=$MKLROOT)
  • CMake version (cmake --version)
  • CMake output log
  • git hash (git log -1 --format=%H)

Steps to reproduce

Please check that the issue is reproducible with the latest revision on master. Include all the steps to reproduce the issue. A short C/C++ program or modified unit tests demonstrating the issue will greatly help with the investigation.

Actual behavior

Describe the behavior you see.

Expected behavior

Describe the behavior you expect.

RadjaHachilif avatar Nov 19 '18 13:11 RadjaHachilif

Hi Radja,

Yeah, our C++ documentation is somewhat incomplete... The behavior that you want to get is controlled at batch normalization descriptor initialization using the following C API / C++ API. There you pass flags that might take one or several bit-masks described here: C API / C++.

So if you don't want Intel MKL-DNN to compute the mean and variance (but rather provide them by yourself) you need to set flags to mkldnn_use_global_stats.

A simple example can be found in our tests, e.g. see here.

emfomenk avatar Nov 19 '18 13:11 emfomenk

Thank you, this really helped.

RadjaHachilif avatar Nov 19 '18 18:11 RadjaHachilif