error Loading onnx model exported from pytorch to matlab

조회 수: 9 (최근 30일)
Yasser Belal
Yasser Belal 2020년 1월 20일
답변: Sivylla Paraskevopoulou 2022년 5월 11일
Hi!
I trained a neural network regression (numerical input/output data) model in Pytorch and I want to load it to MATLAB.
I followed the instructions to do so, firstly by converting the pretrained network from Pytorch to .onnx format.
However when I try to load it to MATLAB environment using the MATLAB Deep Learning Toolbox Converter for ONNX Model Format
network = importONNXNetwork('model.onnx', 'OutputLayerType', 'regression')
, I get the following error:
Only image inputs are supported for import
Does this toolbox converter for onnx, just support models with image inputs?

답변 (2개)

Shashank Gupta
Shashank Gupta 2020년 1월 23일
Hi Yasser,
Yeah right now “importONNXNetwork” only support 3D-sequence-batch tensor or 4D image batch tensor. you can perhaps recode the 2D input as a 4D image batch tensor. In pytorch, an image batch tensor has the layout [batch, channel, height, width]. If the [h,w] input tensor could be recoded as a [h,w,1,1] tensor in pytorch, then that might be importable into a MATLAB “imageInputLayer”. (Or, you may need to omit the batch dimension in pytorch and declare it to be [h,w,1] )
I hope this helps.
  댓글 수: 2
Jan Drgona
Jan Drgona 2020년 5월 11일
Hi Shashank,
Does the same apply to importKerasNetwork?
If so is there any other straightforward way to import standard FCNN from pytorch or tf?
Thanks,
Jan
Richard Crozier
Richard Crozier 2021년 9월 6일
is this a regression, pretty sure I was able to previously import non image based models using this tool?

댓글을 달려면 로그인하십시오.


Sivylla Paraskevopoulou
Sivylla Paraskevopoulou 2022년 5월 11일
Since R2021a, both the importONNXNetwork and importTensorFlowNetwork functions can import a TensorFlow/ONNX input layer or tensor as a featureInputLayer.
For more information on how importONNXNetwork interprets the data format of the ONNX network's input tensors and converts them into MATLAB input layers, see Conversion of ONNX Input and Output Tensors into Built-In MATLAB Layers.
For more information on how importTensorFlowNetwork converts the Input TensorFlow-Keras layer into a MATLAB layer, see TensorFlow-Keras Layers Supported for Conversion into Built-In MATLAB Layers.

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by