Error In Loading Pretrained ShuffleNet ONNX Model

Hi there. Recently I am trying doing one simple experiment on training with ShuffleNet.
The pre-trained shuffleNet ONNX model is here: https://github.com/onnx/models/tree/master/shufflenet

From the tutorial of the loading of ONNX model (https://mxnet.incubator.apache.org/tutorials/onnx/super_resolution.html?highlight=onnx), the simple model loading code is here:

import mxnet.contrib.onnx as onnx_mxnet
import json
def loadShuffleNet():
path = ‘/model/shufflenet/’
onnx_path = path + ‘model.onnx’
sym, arg_params, aux_params = onnx_mxnet.import_model(onnx_path)
print(sym.get_internals().list_outputs())

The error information is on the following:
—> 30 sym, arg_params, aux_params = onnx_mxnet.import_model(onnx_path)
31 print(sym.get_internals().list_outputs())
32 ln = ‘flatten0’

~/.local/lib/python3.6/site-packages/mxnet/contrib/onnx/_import/import_model.py in import_model(model_file)
51 # loads model file and returns ONNX protobuf object
52 model_proto = onnx.load(model_file)
—> 53 sym, arg_params, aux_params = graph.from_onnx(model_proto.graph)
54 return sym, arg_params, aux_params
55

~/.local/lib/python3.6/site-packages/mxnet/contrib/onnx/_import/import_onnx.py in from_onnx(self, graph)
112 onnx_attr = self._parse_attr(node.attribute)
113 inputs = [self._nodes[i] for i in node.input]
–> 114 mxnet_sym = self._convert_operator(node_name, op_name, onnx_attr, inputs)
115
116 for k, i in zip(list(node.output), range(len(mxnet_sym.list_outputs()))):

~/.local/lib/python3.6/site-packages/mxnet/contrib/onnx/_import/import_onnx.py in _convert_operator(self, node_name, op_name, attrs, inputs)
56 “”"
57 if op_name in convert_map:
—> 58 op_name, new_attrs, inputs = convert_map[op_name](attrs, inputs, self)
59 else:
60 raise NotImplementedError(“Operator {} not implemented.”.format(op_name))

~/.local/lib/python3.6/site-packages/mxnet/contrib/onnx/_import/op_translations.py in batch_norm(attrs, inputs, cls)
172
173 # in test mode “fix_gamma” should be unset.
–> 174 new_attrs[‘fix_gamma’] = 0 if new_attrs[‘fix_gamma’] == 1 else 1
175 return ‘BatchNorm’, new_attrs, inputs
176

KeyError: ‘fix_gamma’

After testing with all versions of the pre-trained shuffleNet, only the version 1.1 can be loaded successfully.

Is there anyone meeting this problem? Thank you.

This is due to the discrepancy between ONNX operator Opset versions. Please check comment:

I tried to reproduce the error. Tried both opset 6 and 7 of shufflenet model. It works fine.
Seems like you are using old code. This issue was fixed in latest code.
Can you get latest mxnet and try to run the tutorial again?

Sorry for the late reply. Thank you. The problem has been fixed.