mxnet 1.3.0
i wirte a test program:
class MyNet( HybridBlock ):
def __init__(self, **kwargs):
super( MyNet ,self).__init__(**kwargs)
self.cnn_block = mx.gluon.nn.HybridSequential()
with self.name_scope():
self.cnn_block.add(
#conv1
nn.Conv2D( channels=64,kernel_size=(3,3),strides=(1,1),padding=(1,1)),
nn.Activation("relu"),
nn.BatchNorm(),
nn.MaxPool2D( pool_size=(2, 2), strides=(2, 2), padding=(0, 0) ),
)
def hybrid_forward(self, F, x, *args, **kwargs):
y = self.cnn_block( x )
y = F.transpose(y,axes=(1,2,3,0))
y = F.reshape(y,shape=(0,0,0))
return y
ctx = mx.cpu()
mynet = MyNet()
mynet.initialize( mx.initializer.Xavier(), ctx=ctx )
mynet.hybridize()
fake_x = nd.zeros(shape=(1,3,300,300))
y = mynet( fake_x )
print(y.shape)
mynet.export("./onnx/mynet")
onnx_mxnet.export_model("./onnx/mynet-symbol.json", “./onnx/mynet-0000.params”, [(1,3,300,300)], np.float32, “./onnx/mynet.onnx”)
#######################################################################
the export is ok when the model didn’t contain the BatchNorm layer.
but report error when i add a BatchNorm layer to the model like this:
onnx.onnx_cpp2py_export.checker.ValidationError: Unrecognized attribute: spatial for operator BatchNormalization
call for help