Error: Exporting MXNet model to ONNX format

I wanted to export MXNet model to ONNX format
I was using the following link notebook but got errors

Error Log:
ValidationError: Unrecognized attribute: spatial for operator BatchNormalization

==> Context: Bad node spec: input: “data” input: “bn_data_gamma” input: “bn_data_beta” input: “bn_data_moving_mean” input: “bn_data_moving_var” output: “bn_data” name: “bn_data” op_type: “BatchNormalization” attribute { name: “epsilon” f: 2e-05 type: FLOAT } attribute { name: “momentum” f: 0.9 type: FLOAT } attribute { name: “spatial” i: 0 type: INT }

According to this MXNet supports operation set of version 7, and the last version of ONNX package (1.5.0) supports operation set 9, which has this attribute removed from BatchNorm.

You will need to install onnx package of version 1.3.0 to do the export. Just do:

pip uninstall onnx
pip install onnx==1.3.0

I tried this and it worked fine.