Reputation: 23
What is the difference between Instance normalization and MVN and Batch normalization (training mode and batch_size=1) in onnx?
My pytorch model is currently using instance normalization but my ultimate scope is to convert the model in Openvino (version 2020.3) passing through onnx. There is an incompatibility with this normalization (see link below), only batch normalization (BN) is supported.
BN works the same as instance normalization if batch size is 1 and the training mode is on (here). The conversion in onnx works, outputs are the same, but Openvino struggles a lot to deal with this training_mode=on parameter, which is only a dummy features written somewhere in the exported graph.
I see there is a chance to use MVN instead (compatibility operations onnx-openvino here and here the function, across_channels=false). Onnx seems supporting this operation (here) but I don't know how to use/include it in pytorch, that would be converted in onnx and ultimately supported by openvino. I am not an expert of openvino neither onnx, but this is how life works :).
Is this MVN comparable with instance normalization in pytorch? After retraining a model would I have the same output?
Upvotes: 0
Views: 558
Reputation: 134
MeanVarianceNormalization (MVN) and BatchNormalization are the supported operators for ONNX in OpenVINO toolkit. Refer to the ONNX Supported Operators.
Meanwhile, a usual behavior of Model Optimizer is to fuse batch normalization to the convolution layer. Refer to the Model Cutting and Optimization Description to learn the method of model preparation.
Upvotes: 0