You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@mxnet.apache.org by GitBox <gi...@apache.org> on 2021/11/05 07:28:47 UTC

[GitHub] [incubator-mxnet] JiaoPaner opened a new issue #20727: mxnet model convert to onnx is scuucess but ort.InferenceSession failed

JiaoPaner opened a new issue #20727:
URL: https://github.com/apache/incubator-mxnet/issues/20727


   # Ask a Question
   I success convert mxnet model to onnx  but it failed when inference .The model 's shape is (1,1,100,100)
   **convert code**
   ```
   sym = 'single-symbol.json'
   params = '/single-0090.params'
   input_shape = (1, 1, 100, 100)
   onnx_file = './model.onnx'
   converted_model_path = onnx_mxnet.export_model(sym, params, [input_shape], np.float32, onnx_file,verbose=True)
   model= onnx.load_model(converted_model_path)
   checker.check_graph(model.graph)
   checker.check_model(model)
   ```
   **output**
   ```
   INFO:root:Input shape of the model [(1, 1, 100, 100)] 
   INFO:root:Exported ONNX file ./model.onnx saved to disk
   ```
   
   **inference code**
   ```
   sess = ort.InferenceSession("./model.onnx") 
   ```
   **output**
   ```
   onnxruntime.capi.onnxruntime_pybind11_state.RuntimeException:
    [ONNXRuntimeError] : 6 : RUNTIME_EXCEPTION : 
   Exception during initialization: 
   /onnxruntime/core/providers/cpu/nn/pool_attributes.h:77 
   onnxruntime::PoolAttributes::PoolAttributes(const OpNodeProtoHelper<onnxruntime::ProtoHelperNodeContext> &,
                                                     const std::string &, int) pads[dim] < kernel_shape[dim] &&
                                                     pads[dim + kernel_shape.size()] < kernel_shape[dim] was false. 
   Pad should be smaller than kernel.
   ```
   ### Question
   **mxnet pooling node json**
   ```
   {
     "op": "Pooling", 
     "name": "pool1_fwd", 
     "attrs": {
       "count_include_pad": "True", 
       "global_pool": "False", 
       "kernel": "(4, 4)", 
       "layout": "NCHW", 
       "pad": "(4, 4)", 
       "pool_type": "avg", 
       "pooling_convention": "valid", 
       "stride": "(4, 4)"
     }, 
     "inputs": [[46, 0, 0]]
   }
   ```
   I change the "pad": "(4, 4)" to "pad": "(3, 3)" smaller than "kernel": "(4, 4), then try convert again.
   ```
   sess = ort.InferenceSession("./model.onnx")
   output = sess.run(None, {"data": data.astype(np.float32)})
   ``` 
   it worked,but the output value is not right.
   how to fix it ?
   BTW:convert the mxnet model to ncnn all is right(not change anything,pad=(4,4),kernel=(4,4))
   
   ### Further information
   python:3.8
   onnx:1.10.2
   mxnet:1.8.0
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@mxnet.apache.org
For additional commands, e-mail: issues-help@mxnet.apache.org


[GitHub] [incubator-mxnet] github-actions[bot] commented on issue #20727: mxnet model convert to onnx is scuucess but ort.InferenceSession failed

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on issue #20727:
URL: https://github.com/apache/incubator-mxnet/issues/20727#issuecomment-961679980


   Welcome to Apache MXNet (incubating)! We are on a mission to democratize AI, and we are glad that you are contributing to it by opening this issue.
   Please make sure to include all the relevant context, and one of the @apache/mxnet-committers will be here shortly.
   If you are interested in contributing to our project, let us know! Also, be sure to check out our guide on [contributing to MXNet](https://mxnet.apache.org/community/contribute) and our [development guides wiki](https://cwiki.apache.org/confluence/display/MXNET/Developments).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@mxnet.apache.org
For additional commands, e-mail: issues-help@mxnet.apache.org


[GitHub] [incubator-mxnet] JiaoPaner commented on issue #20727: mxnet model convert to onnx is scuucess but ort.InferenceSession failed

Posted by GitBox <gi...@apache.org>.
JiaoPaner commented on issue #20727:
URL: https://github.com/apache/incubator-mxnet/issues/20727#issuecomment-966290846


   I fix it,recode model by pytorch and copy weights,use nn.ZeroPad2d(4) before avgpooling:
   ```
   self.pad = nn.ZeroPad2d(4)
   self.pool = nn.AvgPool2d(kernel_size=(4,4),stride=(4,4))
   
   X = self.pool(self.pad(self.conv(X)))
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@mxnet.apache.org
For additional commands, e-mail: issues-help@mxnet.apache.org


[GitHub] [incubator-mxnet] github-actions[bot] commented on issue #20727: mxnet model convert to onnx is scuucess but ort.InferenceSession failed

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on issue #20727:
URL: https://github.com/apache/incubator-mxnet/issues/20727#issuecomment-961679980


   Welcome to Apache MXNet (incubating)! We are on a mission to democratize AI, and we are glad that you are contributing to it by opening this issue.
   Please make sure to include all the relevant context, and one of the @apache/mxnet-committers will be here shortly.
   If you are interested in contributing to our project, let us know! Also, be sure to check out our guide on [contributing to MXNet](https://mxnet.apache.org/community/contribute) and our [development guides wiki](https://cwiki.apache.org/confluence/display/MXNET/Developments).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@mxnet.apache.org
For additional commands, e-mail: issues-help@mxnet.apache.org


[GitHub] [incubator-mxnet] JiaoPaner closed issue #20727: mxnet model convert to onnx is scuucess but ort.InferenceSession failed

Posted by GitBox <gi...@apache.org>.
JiaoPaner closed issue #20727:
URL: https://github.com/apache/incubator-mxnet/issues/20727


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@mxnet.apache.org
For additional commands, e-mail: issues-help@mxnet.apache.org


[GitHub] [incubator-mxnet] github-actions[bot] commented on issue #20727: mxnet model convert to onnx is scuucess but ort.InferenceSession failed

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on issue #20727:
URL: https://github.com/apache/incubator-mxnet/issues/20727#issuecomment-961679980


   Welcome to Apache MXNet (incubating)! We are on a mission to democratize AI, and we are glad that you are contributing to it by opening this issue.
   Please make sure to include all the relevant context, and one of the @apache/mxnet-committers will be here shortly.
   If you are interested in contributing to our project, let us know! Also, be sure to check out our guide on [contributing to MXNet](https://mxnet.apache.org/community/contribute) and our [development guides wiki](https://cwiki.apache.org/confluence/display/MXNET/Developments).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@mxnet.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@mxnet.apache.org
For additional commands, e-mail: issues-help@mxnet.apache.org