tensorflow-onnx icon indicating copy to clipboard operation
tensorflow-onnx copied to clipboard

Batch normalization layer from Keras only converts to BatchNormalization op if dims >= 4

Open ewenw opened this issue 1 year ago • 1 comments

Hi Onnx team, I'm running into a model conversion issue for Kera's BatchNorm layer. The BatchNorm layer is only converted into a BatchNorm Op in Onnx when input Dim>=4. I believe this stems from the fact that the tf-onnx converter will only convert as a BatchNorm Op if the original TF Op is a FusedBatchNorm operator. Currently, my work around is to expand_dim the input so that the BatchNorm Op is inserted by the converter, otherwise it just becomes a single Mul op. This is problematic for training.

With 4D input: MicrosoftTeams-image (1)

With 3D input: MicrosoftTeams-image (2)

ewenw avatar Aug 09 '23 02:08 ewenw

Is that possible to share a code snippet for a repro?

fatcat-z avatar Aug 25 '23 11:08 fatcat-z