【问题标题】:how to save in pytorch an ONNX model with training (autograd) operations?如何在 pytorch 中保存带有训练(autograd)操作的 ONNX 模型?
【发布时间】:2021-10-10 19:08:03
【问题描述】:

在 pytorch 中,是否可以将 ONNX 模型保存到文件中,包括反向操作? 如果没有,pytorch中是否有其他方法可以将前向和后向图保存为文本(json,pbtxt ...)?

任何帮助将不胜感激。

【问题讨论】:

    标签: pytorch onnx


    【解决方案1】:

    如果你用 ORTModule 包装模型是可能的 - https://github.com/microsoft/onnxruntime-training-examples 有启用 onnx 模型保存的标志,例如: model._save_onnx = True model._save_onnx_prefix = 'MNIST' 但是,在生成 bw 图之前,将进一步优化来自 fw 的 onnx 图。因此它特定于 ORT,但训练结果在数学上应该是相同的。如果您只是在寻找 fw+bw 图,输出 onnx 仍然是一个很好的参考。可以使用 Netron util 打开 onnx - https://github.com/lutzroeder/Netron

    【讨论】:

    猜你喜欢
    • 2019-06-12
    • 2021-05-24
    • 2021-10-04
    • 2021-09-11
    • 2018-01-03
    • 2019-09-11
    • 2021-12-19
    • 1970-01-01
    • 2014-02-28
    相关资源
    最近更新 更多