pytorch ssd模型导出onnx 转paddle出错
Created by: luoduo21
Now translating model from onnx to paddle. model ir_version: 4, op version: 9 Total nodes: 98 Traceback (most recent call last): File "/home/zt/androidprojects/X2Paddle-develop/x2paddle/core/op_mapper.py", line 122, in save_inference_model inputs, outputs = model.x2paddle_net() File "pd_model/model_with_code/model.py", line 7, in x2paddle_net _107 = fluid.layers.create_parameter(dtype='float32', shape=[], name='_107', attr='_107', default_initializer=Constant(0.0)) File "/home/zt/tools/anaconda3/envs/pytorch1.3/lib/python3.6/site-packages/paddle/fluid/layers/tensor.py", line 103, in create_parameter default_initializer) File "/home/zt/tools/anaconda3/envs/pytorch1.3/lib/python3.6/site-packages/paddle/fluid/layer_helper_base.py", line 330, in create_parameter **attr._to_kwargs(with_initializer=True)) File "/home/zt/tools/anaconda3/envs/pytorch1.3/lib/python3.6/site-packages/paddle/fluid/framework.py", line 2384, in create_parameter param = Parameter(global_block, *args, **kwargs) File "/home/zt/tools/anaconda3/envs/pytorch1.3/lib/python3.6/site-packages/paddle/fluid/framework.py", line 4471, in init "The dimensions of shape for Parameter must be greater than 0") ValueError: The dimensions of shape for Parameter must be greater than 0
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "/home/zt/tools/anaconda3/envs/pytorch1.3/bin/x2paddle", line 11, in load_entry_point('x2paddle==0.6.0', 'console_scripts', 'x2paddle')() File "/home/zt/androidprojects/X2Paddle-develop/x2paddle/convert.py", line 233, in main onnx2paddle(args.model, args.save_dir, params_merge) File "/home/zt/androidprojects/X2Paddle-develop/x2paddle/convert.py", line 176, in onnx2paddle mapper.save_inference_model(save_dir, params_merge) File "/home/zt/androidprojects/X2Paddle-develop/x2paddle/core/op_mapper.py", line 158, in save_inference_model .format(py_code_dir)) Exception: Paddle code was saved in pd_model/model_with_code/model.py, but seems there's wrong exist, please check model.py manually.
onnx文件先经过onnx-simplifier-master工具转化过,出错的地方为L2Norm部分,不知道是不是因为_107处常量没有scope.
%106 : Float(1, 1024, 19, 19) = onnx::Relu(%105), scope: SSD/VGG16[base]/ReLU # /home/zt/tools/anaconda3/envs/pytorch1.3/lib/python3.6/site-packages/torch/nn/functional.py:914:0 %107 : Float() = onnx::Constantvalue={2} %108 : Float(1, 512, 38, 38) = onnx::Pow(%94, %107), scope: SSD/L2Norm[L2Norm] # /home/zt/PycharmProjects/fssd.pytorch-master/models/SSD_vgg.py:268:0