【发布时间】:2022-01-17 00:25:30
【问题描述】:
我打算从 pth 文件加载权重,例如,
model = my_model()
model.load_state_dict(torch.load("../input/checkpoint/checkpoint.pth")
但是,这里有一个错误,说:
RuntimeError: Error(s) in loading state_dict for my_model:
Missing key(s) in state_dict: "att.in_proj_weight", "att.in_proj_bias", "att.out_proj.weight", "att.out_proj.bias".
Unexpected key(s) in state_dict: "in_proj_weight", "in_proj_bias", "out_proj.weight", "out_proj.bias".
似乎我的模型的参数名称与state_dict中存储的参数名称不同。在这种情况下,我应该如何使它们保持一致?
【问题讨论】:
标签: python machine-learning deep-learning neural-network pytorch