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:

From the tutorial of the loading of ONNX model (, 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)

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/ 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

~/.local/lib/python3.6/site-packages/mxnet/contrib/onnx/_import/ 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)
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/ 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/ in batch_norm(attrs, inputs, cls)
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

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.