-
Notifications
You must be signed in to change notification settings - Fork 6.8k
convert from mxnet to onnx failed, with Unrecognized attribute: spatial for operator BatchNormalization #14589
Comments
Hey, this is the MXNet Label Bot. |
onnx version 1.4.1 |
@dongjunjundong Please try using ONNX v1.3.0. Exporting with ONNX 1.3.0 worked for me. |
Maybe mxnet should target a specific opset then. Or at the very least have a check in there that errors out with a sane error message when onnx is too new... |
Same problem, you can remove the 'spatial' attribute of batchnorm from the python file (output of error info)! |
I have convert mxnet(1.5.0) to the onnx(1.5.0), the error is: `INFO:root:Converting idx: 3, op: null, name: first-3x3-conv-batchnorm_gamma Original exception was:
|
the moving_mean is in the auxs param. just merge args and auxs. |
@mxnet-label-bot 2, delete line 359: spatial=0 It works for me tranlate .params and json to onnx, but this failed me for inference in tensorRT 5.1.5. It should be another problem though I'm not sure about that. |
Did you run into this ? Have you solved it? |
The model-symbol.json file I had did not have spatial attribute. Still it failed. I noticed that the mxnet-onnx converter was adding that attribute as below: |
Can you please tell me how to export with onnx 1.3 since we are using onnx from mxnet ? |
cc @josephevans who's working on ONNX improvements. |
the latest mxnet 1.7.0 haven't sovled the issue yet. |
Hi @Brightchu, we have been working on ONNX support on the v1.x branch lately. We added support for onnx 1.7 and 100s of new models. Would you share your specific export use case so that we can prioritize it? |
hi, thanks for your reply. |
@Brightchu Thanks for the message. I checked onnx's op doc and batchnorm used to have an attribute called spatial. This attribute is no longer there in the new op set/newer onnx. We have noted this down and we will bring our batchnorm conversion up to date to the current onnx specification. Our work-in-progress onnx 1.7 support has covered many more cv and nlp models (and more modern models). We are going to publish docs/blog posts very soon. If you are interested in trying that out please let use know how we can help or dubug your use case |
I use “pip install onnx==1.3.0”,and it solved |
Description
Failed to convert pretrained mode cifar_resnet110_v1 from mxnet format to onnx;
Environment info (Required)
using the mxnet zoo pre trained module cifar_resnet110_v1
mxnet version 1.5.0
the convert call is below:
input_shape = [(1,3,32,32)]
export_model("simple_net-symbol.json","simple_net-0000.params",input_shape)
Error Message:
(Paste the complete error message, including stack trace.)
~/ENV/lib/python3.5/site-packages/onnx/checker.py in checker(proto, ctx)
50 proto_type.name))
51 return getattr(C, py_func.name)(
---> 52 proto.SerializeToString(), ctx)
53 return cast(FuncType, checker)
54 return decorator
ValidationError: Unrecognized attribute: spatial for operator BatchNormalization
==> Context: Bad node spec: input: "cifarresnetv10_conv0_fwd" input: "cifarresnetv10_batchnorm0_gamma" input: "cifarresnetv10_batchnorm0_beta" input: "cifarresnetv10_batchnorm0_running_mean" input: "cifarresnetv10_batchnorm0_running_var" output: "cifarresnetv10_batchnorm0_fwd" name: "cifarresnetv10_batchnorm0_fwd" op_type: "BatchNormalization" attribute { name: "epsilon" f: 1e-05 type: FLOAT } attribute { name: "momentum" f: 0.9 type: FLOAT } attribute { name: "spatial" i: 0 type: INT }
The text was updated successfully, but these errors were encountered: