Torch7 训练模型 (.t7) 在 PyTorch 库中加载错误

问题描述 投票:0回答:1

我需要 this repo 中的预训练模型,但它以 t7 格式保存 有没有什么方法或工具可以在当前的pytorch环境中使用它

我尝试了存储库convert_torch_to_pytorch,但面临着torch.legacy的ModuleNotFoundError和ModuleNotFoundError:没有名为“torch.utils.serialization”的模块

python deep-learning pytorch torch
1个回答
0
投票

您应该仍然能够在当前

.t7
版本中加载
PyTorch
权重。这是示例代码片段:

model = Your_model() # Call your model class here
checkpoint = torch.load('/path/to/checkpoint.t7')
model.load_state_dict(checkpoint['state_dict'])

如果您有多个 GPU,这个线程将为您提供更多见解。

© www.soinside.com 2019 - 2024. All rights reserved.