【问题标题】:Building models in ONNX在 ONNX 中构建模型
【发布时间】:2020-06-13 04:06:15
【问题描述】:

是否可以在不使用其他深度学习框架(例如 PyTorch、TensorFlow 等)的情况下在 ONNX 中构建模型?

在 PyTorch 中,我会写一个这样的模型:

import torch.nn as nn
import torch.nn.functional as F

class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.conv1 = nn.Conv2d(3, 6, 5)
        self.pool = nn.MaxPool2d(2, 2)
        self.conv2 = nn.Conv2d(6, 16, 5)
        self.fc1 = nn.Linear(16 * 5 * 5, 120)
        self.fc2 = nn.Linear(120, 84)
        self.fc3 = nn.Linear(84, 10)

    def forward(self, x):
        x = self.pool(F.relu(self.conv1(x)))
        x = self.pool(F.relu(self.conv2(x)))
        x = x.view(-1, 16 * 5 * 5)
        x = F.relu(self.fc1(x))
        x = F.relu(self.fc2(x))
        x = self.fc3(x)
        return x

net = Net()

在 ONNX 中定义一个相同的模型相当于什么?我了解如何导出模型,但我想在不使用外部库的情况下使用 ONNX。

【问题讨论】:

    标签: python onnx onnxruntime


    【解决方案1】:

    到目前为止,您可以使用 ONNXRuntime 对模型进行推理并更快地训练您的模型,但无法使用 ONNX 构建模型。以供参考, https://cloudblogs.microsoft.com/opensource/2020/05/19/announcing-support-for-accelerated-training-with-onnx-runtime/

    【讨论】:

      猜你喜欢
      • 2020-03-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-08
      • 2018-10-05
      • 2021-02-03
      相关资源
      最近更新 更多