could not export python function call Remove calls to Python functions before export

目录

set_swish

Could not export Python function call 'Scatter'

nn.Module的子类也需要是torch.jit.ScriptModule


set_swish

could not export python function call <python_value>. Remove calls to Python functions before export. Did you forget add @script or @script_method annotation? If this is a nn.ModuleList, add it to __constants__.:
 

trace efficientnet的时侯遇到的错,解决方案是set_swish,

    net = EfficientNet.from_name('efficientnet-b4')  
    net.set_swish(memory_efficient=False)
    trace_model(net,'Efficientent_b4_best.ckpt')


原文链接:https://blog.csdn.net/qq_16542771/article/details/113000043

Could not export Python function call 'Scatter'

用pytorch的 trace 导出模型的时候,报错

error

RuntimeError: 
Could not export Python function call 'Scatter'. Remove calls to Python functions before export. Did you forget to add @script or @script_method annotation? If this is a nn.ModuleList, add it to __constants__:
/usr/local/lib/python3.7/dist-packages/torch/nn/parallel/scatter_gather.py(13): scatter_map
/usr/local/lib/python3.7/dist-packages/torch/nn/parallel/scatter_gather.py(15): scatter_map
/usr/local/lib/python3.7/dist-packages/torch/nn/parallel/scatter_gather.py(28): scatter
/usr/local/lib/python3.7/dist-packages/torch/nn/parallel/scatter_gather.py(36): scatter_kwargs
/usr/local/lib/python3.7/dist-packages/torch/nn/parallel/data_parallel.py(168): scatter
/usr/local/lib/python3.7/dist-packages/torch/nn/parallel/data_parallel.py(157): forward
/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py(709): _slow_forward
/usr/local/lib/python3.7/dist-packages/torch/nn/modules/module.py(725): _call_impl
/usr/local/lib/python3.7/dist-packages/torch/jit/_trace.py(940): trace_module
/usr/local/lib/python3.7/dist-packages/torch/jit/_trace.py(742): trace
<ipython-input-14-e92379b43790>(2): <module>



解决方案
将model改为
model = model.module

原文链接:https://blog.csdn.net/u011622208/article/details/124154491

nn.Module的子类也需要是torch.jit.ScriptModule

could not export python function call <python_value>. Remove calls to Python functions before export

nn.Module的子类也需要是torch.jit.ScriptModule

https://www.twblogs.net/a/5d13a9a4bd9eee1ede04f6fe/?lang=zh-cn

这个还没看:

Unsupported ops in StyleGAN2 - #8 by Wheest - Troubleshooting - Apache TVM Discuss

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 7
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AI算法网奇

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值