PaddlePaddle / X2Paddle

Deep learning model converter for PaddlePaddle. (『飞桨』深度学习模型转换工具)
http://www.paddlepaddle.org/
Apache License 2.0
717 stars 162 forks source link

TwinLiteNet:pytorch转onnx转paddle报错 #999

Open Boyangzh opened 7 months ago

Boyangzh commented 7 months ago

问题描述

TwinLiteNet:pytorch转onnx转paddle报错

W1117 13:07:37.444545 392280 gpu_resources.cc:61] Please NOTE: device: 0, GPU Compute Capability: 7.5, Driver API Version: 11.7, Runtime API Version: 10.2 W1117 13:07:37.445227 392280 gpu_resources.cc:91] device: 0, cuDNN Version: 8.7. /opt/anaconda3/envs/paddle2.4_py3.7/lib/python3.7/site-packages/paddle/fluid/dygraph/layers.py:1652: UserWarning: Skip loading for conv2.weight. conv2.weight receives a shape [12, 19, 3, 3], but the expected shape is [12, 64, 3, 3]. warnings.warn(("Skip loading for {}. ".format(key) + str(err))) /opt/anaconda3/envs/paddle2.4_py3.7/lib/python3.7/site-packages/paddle/fluid/dygraph/layers.py:1652: UserWarning: Skip loading for conv8.weight. conv8.weight receives a shape [12, 19, 3, 3], but the expected shape is [12, 64, 1, 1]. warnings.warn(("Skip loading for {}. ".format(key) + str(err))) /opt/anaconda3/envs/paddle2.4_py3.7/lib/python3.7/site-packages/paddle/fluid/dygraph/layers.py:1652: UserWarning: Skip loading for conv21.weight. conv21.weight receives a shape [25, 131, 3, 3], but the expected shape is [25, 128, 3, 3]. warnings.warn(("Skip loading for {}. ".format(key) + str(err))) /opt/anaconda3/envs/paddle2.4_py3.7/lib/python3.7/site-packages/paddle/fluid/dygraph/layers.py:1652: UserWarning: Skip loading for conv27.weight. conv27.weight receives a shape [25, 131, 3, 3], but the expected shape is [25, 128, 1, 1]. warnings.warn(("Skip loading for {}. ".format(key) + str(err))) In transformed code:

File "pd_model/x2paddle_code.py", line 116, in forward
    x2paddle_440 = self.conv1(x2paddle_194)
    x2paddle_198 = self.prelu1(x2paddle_440)
    x2paddle_199 = self.conv2(x2paddle_198)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
    x2paddle_200 = self.conv3(x2paddle_199)
    x2paddle_201 = self.conv4(x2paddle_199)

File "/opt/anaconda3/envs/paddle2.4_py3.7/lib/python3.7/site-packages/paddle/fluid/dygraph/layers.py", line 1014, in __call__
return self._dygraph_call_func(*inputs, **kwargs)
File "/opt/anaconda3/envs/paddle2.4_py3.7/lib/python3.7/site-packages/paddle/fluid/dygraph/layers.py", line 993, in _dygraph_call_func
outputs = self.forward(*inputs, **kwargs)
File "/opt/anaconda3/envs/paddle2.4_py3.7/lib/python3.7/site-packages/paddle/nn/layer/conv.py", line 724, in forward
use_cudnn=self._use_cudnn,
File "/opt/anaconda3/envs/paddle2.4_py3.7/lib/python3.7/site-packages/paddle/nn/functional/conv.py", line 277, in _conv_nd
type=op_type, inputs=inputs, outputs=outputs, attrs=attrs
File "/opt/anaconda3/envs/paddle2.4_py3.7/lib/python3.7/site-packages/paddle/fluid/layer_helper.py", line 45, in append_op
return self.main_program.current_block().append_op(*args, **kwargs)
File "/opt/anaconda3/envs/paddle2.4_py3.7/lib/python3.7/site-packages/paddle/fluid/framework.py", line 4046, in append_op
attrs=kwargs.get("attrs", None),
File "/opt/anaconda3/envs/paddle2.4_py3.7/lib/python3.7/site-packages/paddle/fluid/framework.py", line 3037, in __init__
self.desc.infer_shape(self.block.desc)

ValueError: (InvalidArgument) The number of input's channels should be equal to filter's channels * groups for Op(Conv). But received: the input's channels is 19, the input's shape is [1, 19, 180, 320]; the filter's channels is 64, the filter's shape is [12, 64, 3, 3]; the groups is 1, the data_format is NCHW. The error may come from wrong data_format setting.

[Hint: Expected input_channels == filter_dims[1] groups, but received input_channels:19 != filter_dims[1] groups:64.] (at /paddle/paddle/fluid/operators/conv_op.cc:131) [operator < conv2d > error]

来源框架版本(PyTorch/TF/ONNX/Caffe) => :PyTorch->onnx