Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请问如何加载预训练模型 #17

Closed
csbbbv opened this issue Oct 11, 2021 · 0 comments
Closed

请问如何加载预训练模型 #17

csbbbv opened this issue Oct 11, 2021 · 0 comments

Comments

@csbbbv
Copy link

csbbbv commented Oct 11, 2021

`

if name == "main":
vocabulary = joblib.load(LABEL_PATH)
vocabulary = "".join(vocabulary)
model = GatedConv(vocabulary)
pretrained = torch.load("pretrained/model_49.pth")
pretrain_dict = pretrained.state_dict()
new_state_dict = OrderedDict()
for k, v in pretrain_dict.items():
name = k[7:]
new_state_dict[name] = v
model = model.load_state_dict(new_state_dict)
model = nn.DataParallel(model)
model.cuda()
train(model)

`
这是我的代码,加载完模型字典后模型参数都丢失了
image

image

@csbbbv csbbbv closed this as completed Oct 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant