【问题标题】:In pytorch torchscript, how to compile with multi heads?在pytorch torchscript中,如何进行多头编译?
【发布时间】:2022-12-04 00:43:51
【问题描述】:

我有一个有多个可选的模型 heads 并想编译成 torchscript。

有没有办法正确编译?

我试图搜索,但最接近的答案是这个, 它不提供任何解决方法。 https://discuss.pytorch.org/t/using-torschscript-to-save-a-model-with-multiple-heads/158709

【问题讨论】:

    标签: pytorch torchscript


    【解决方案1】:

    是的,您可以使用 torch.jit.trace 或 torch.jit.script 函数将 PyTorch 模型编译成 TorchScript。如果您的模型有多个可选头,您可以通过将头的名称作为参数传递给 torch.jit.trace 或 torch.jit.script 函数来指定在跟踪或编写模型脚本时使用哪个头

    【讨论】:

      猜你喜欢
      • 2022-12-03
      • 2021-06-12
      • 1970-01-01
      • 2016-06-30
      • 2019-05-18
      • 2013-03-05
      • 2015-03-17
      • 1970-01-01
      • 2019-08-16
      相关资源
      最近更新 更多