wangliye00 opened a new issue #13949: Error: shape inconsistent while converting PyTorch model to mxnet model with onnx URL: https://github.com/apache/incubator-mxnet/issues/13949 ## Description I tried to convert a pretrained pytorch resnet18 to onnx format, then to mxnet model. But shape inconsistent error occurred when I load the onnx file with mxnet.contrib.onnx module. ## Environment info (Required) - PyTorch 1.0, mxnet 1.3.0 (for windows) ``` ## Error Message: File “D:\software\Anaconda3\lib\site-packages\mxnet\contrib\onnx\onnx2mx\import_model.py”, line 53, in import_model sym, arg_params, aux_params = graph.from_onnx(model_proto.graph) File “D:\software\Anaconda3\lib\site-packages\mxnet\contrib\onnx\onnx2mx\import_onnx.py”, line 96, in from_onnx self._params[init_tensor.name] = self._parse_array(init_tensor) File “D:\software\Anaconda3\lib\site-packages\mxnet\contrib\onnx\onnx2mx\import_onnx.py”, line 200, in _parse_array return nd.array(np_array) File “D:\software\Anaconda3\lib\site-packages\mxnet\ndarray\utils.py”, line 146, in array return _array(source_array, ctx=ctx, dtype=dtype) File “D:\software\Anaconda3\lib\site-packages\mxnet\ndarray\ndarray.py”, line 2435, in array arr[:] = source_array File “D:\software\Anaconda3\lib\site-packages\mxnet\ndarray\ndarray.py”, line 444, in setitem self._set_nd_basic_indexing(key, value) File “D:\software\Anaconda3\lib\site-packages\mxnet\ndarray\ndarray.py”, line 710, in _set_nd_basic_indexing self._sync_copyfrom(value) File “D:\software\Anaconda3\lib\site-packages\mxnet\ndarray\ndarray.py”, line 872, in _sync_copyfrom str(self.shape), str(source_array.shape))) ValueError: Shape inconsistent: expected () vs got (1,) ## Minimum reproducible example import torch import torchvision dummy_input = torch.randn(1, 3, 224, 224) model = torchvision.models.resnet18(pretrained=True) input_names = [ “input_1" ] output_names = [ “output1” ] torch.onnx.export(model, dummy_input, “resnet.onnx”, verbose=True, input_names=input_names, output_names=output_names) from mxnet.contrib import onnx as onnx_mxnet sym, arg, aux = onnx_mxnet.import_model(“resnet.onnx”)
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services