为了实现这一点,我决定使用TorchScript,因为这似乎是唯一可行的方法。_model(x))
这很好,直到我没有尝试使用torchscript序列化它。task_head_models' (This attribute exists on the Python module, but we failed to convert Python type: 'dict' to a TorchScript
当在torchscript中使用时,Torch.cat会抛出张量列表错误import torchSmallestworking bug for torch.cat torchscript
"""dummy model for showing errorThe original call is:
at smalles
我被这个错误This attribute exists on the Python module, but we failed to convert Python type: 'Vocab' to a TorchScriptvocab' (This attribute exists on the Python module, but we failed to convert Python type: 'Vocab' to a TorchScript~ <--- HERE
print("
我正在尝试将PyTorch 模型转换为TorchScript。TorchScript requires source access in order to carry out compilation, make sure original .py files are因此,据我所知,在CPython中实现的类不能被TorchScript编译器读取。我没有找到任何纯Python实现。我怎样才能克服这个问题?