如何将ONNX转换回PTH格式
我有一个以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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有本机解决方案,有些人目前正在从事它: https://github.com/enot-com.com/enot----- autodl/onnx2torch
也要清楚,
.pth
检查点,通常仅包含参数,例如权重,偏见...而不是诸如conv2d
,batchnorm2d
,pooling
。另一方面,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 likeconv2d
,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.