RuntimeError: Exporting the operator prim_DictConstruct to ONNX opset version 11 is not supported.

【踩坑】

RuntimeError: Exporting the operator prim_DictConstruct to ONNX opset version 11 is not supported. Please open a bug to request ONNX export support for the missing operator.

RuntimeError: Exporting the operator prim_DictConstruct to ONNX opset version 11 is not supported._第1张图片

 问题场景:因为模型是多输出,模型输出本来是字典格式,在pytorch 保存pth转onnx时,出现无法支持字典操作,转模型格式报出错误。

解决:直接把网络输出格式更改。
 

# 把需要输出的字典 value 转 列表格式

out_values_list = []
out_key_list = ['prob', 'prob_logit', 'prob_map','height_prob','height_prob_logit',
                'center_mask', 'visit_mask', 'center_idx', 'offset', 'edge_map',
                 'seg_map']
for out_s in out_key_list:
     out_values_list.append(out[out_s])
print('test forward out keys:',out.keys())
out = tuple(out_values_list)

RuntimeError: Exporting the operator prim_DictConstruct to ONNX opset version 11 is not supported._第2张图片

 

Reference:

1.ONNX动态输入尺寸的问题【多输出/多输入】【pytorch/onnx/onnxruntime】
 

你可能感兴趣的:(开发工具,python,linux,pytorch,人工智能,python)