深度阅读

torch模型导出到onnx问题 expected 1 dims but tensor has 2

作者
作者
2023年08月22日
更新时间
5.84 分钟
阅读时间
0
阅读量

导出过程中出现如下错误


expected 1 dims but tensor has 2

torch 1.5.0 must be used for the export because the following error occurs intorch 1.6.0 caused by the internal optimization process.
File “/usr/local/lib/python3.7/site-packages/torch/onnx/utils.py”, line 409, in _model_to_graph
export_onnx_opset_version)
RuntimeError: expected 1 dims but tensor has 2
==============================================

参考出处
https://medium.com/axinc-ai/st-gcn-a-machine-learning-model-for-detecting-human-actions-from-skeletons-46a95b31b5db

核心就是版本问题,换个版本就解决了。

推理和训练阶段可以写的不一样,推理尽可能的整合为好。

博客作者

热爱技术,乐于分享,持续学习。专注于Web开发、系统架构设计和人工智能领域。