如何将ONNX转换回PTH格式

发布于 2025-02-07 23:24:14 字数 159 浏览 3 评论 0原文

我有一个以ONNX格式的模型,我想在Fastai Learner中运行它。可能是

learn = learn.load('model.onnx')

另一种方法是转换回PTH格式,但我看不到此任务上任何适当的库。我需要您的任何一种方法。谢谢。

I have a model in onnx format, and I want to run it in fastai learner. possibly something like this

learn = learn.load('model.onnx')

another way is to convert back to pth format, but I dont see any proper library on this task. I need your help in either one of this approach. Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

三生一梦 2025-02-14 23:24:14

没有本机解决方案,有些人目前正在从事它: https://github.com/enot-com.com/enot----- autodl/onnx2torch

也要清楚,.pth检查点,通常仅包含参数,例如权重,偏见...而不是诸如conv2dbatchnorm2dpooling。另一方面,ONNX模型同时包含操作和参数,这就是您可以推断它们的原因。如果从ONNX中,您只需要权重&为了将状态加载到已经实现的火炬模型中,偏见可能很容易,如果您想自动从ONNX构建火炬模型,那是困难的部分。

There is no native solution and some people are currently working on it : https://github.com/ENOT-AutoDL/onnx2torch

Also to be clear, a .pth checkpoint , usually only contains the parameters such as weights, biases... not the operations like conv2d, batchnorm2d, pooling. An onnx model, in another hand, contains both operations and parameters that's why you can infer them. If, from an onnx, you only need the weights & biases in order to load a state into a torch model already implemented, it might be quite easy, if you want to automatically build a torch model from an onnx, that's the hard part.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文