目录
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