小编hau*_*to3的帖子

未找到文件:Python Pytorch 上的 archive/constants.pkl

我在准备序列化 torchscript 模型的运算符列表时遇到错误。这里有什么问题呢?加载的时候就来了吗?

Python代码

# Dump list of operators used by MobileNetV2:
import torch, yaml

root = '/content/drive/My Drive/Monitoring/'
model = torch.jit.load(root+'model.pt')
ops = torch.jit.export_opnames(model)
with open('MobileNetV2.yaml', 'w') as output:
    yaml.dump(ops, output)

Run Code Online (Sandbox Code Playgroud)

堆栈跟踪

    ---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-39-8b61c35fb898> in <module>()
      3 
      4 root = '/content/drive/My Drive/Monitoring/'
----> 5 model = torch.jit.load(root+'model.pt')
      6 ops = torch.jit.export_opnames(model)
      7 with open('MobileNetV2.yaml', 'w') as output:

/usr/local/lib/python3.6/dist-packages/torch/jit/_serialization.py in load(f, map_location, _extra_files)
    159     cu = torch._C.CompilationUnit()
    160     if isinstance(f, str) or isinstance(f, pathlib.Path): …
Run Code Online (Sandbox Code Playgroud)

python serialization pytorch torchvision

5
推荐指数
1
解决办法
4843
查看次数

标签 统计

python ×1

pytorch ×1

serialization ×1

torchvision ×1