关于 ONNX export failed: Couldn‘t export operator aten::upsample_bilinear2d 解决方案

关于torch导出onnx时候无法导出 upsample_bilinear2d的问题:
有人说直接将bilinear换成nearest,但是模型效果自然打折扣
完美的解决方案如下

torch.onnx.export(model, dummy_tensor, output, export_params=True,opset_version=11)
1
这里只需要在后面多加一个 opset_version = 11 就可以解决
但是前提是你的pytorch版本需要大于1.3.0

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
在将模型转换为 ONNX 格式时,可能会出现一些错误,下面是一些常见的错误汇总及解决方法: 1. AttributeError: module 'torch.onnx' has no attribute 'OperatorExportTypes' 解决方法:更新 PyTorch 版本至 1.7 以上。 2. TypeError: Forward is not a function 解决方法:检查模型的 forward 函数是否写正确。 3. TypeError: can't pickle torch.Tensor objects 解决方法:将模型中的所有 tensor 转换为 numpy 数组。 4. ValueError: ONNX export failed: Couldn't export operator aten::upsample_bilinear2d 解决方法:将上采样函数改为 interpolate 函数。 5. RuntimeError: ONNX export failed: Couldn't export operator aten::max_pool2d 解决方法:将模型中的 max_pool 函数改为 adaptive_max_pool 函数。 6. RuntimeError: ONNX export failed: Couldn't export operator aten::mm 解决方法:将模型中的 mm 函数改为 matmul 函数。 7. RuntimeError: ONNX export failed: Couldn't export operator aten::addmm 解决方法:将模型中的 addmm 函数改为 matmul 函数与 add 函数相结合。 8. RuntimeError: ONNX export failed: Could not export Cast 解决方法:将 Cast 函数改为 astype 函数。 9. RuntimeError: ONNX export failed: Could not export Expand 解决方法:将 Expand 函数改为 broadcast_to 函数。 10. RuntimeError: ONNX export failed: Could not export Gather 解决方法:将 Gather 函数改为 gather 函数。 需要注意的是,在转换模型时,需要保证模型的版本兼容性,以及选择适当的 ONNX 运行时。同时,也需要确保模型的输入输出格式正确,以便后续使用。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值