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

How can I load pretrained model? #34

Open
dlwlgus53 opened this issue Sep 28, 2021 · 1 comment
Open

How can I load pretrained model? #34

dlwlgus53 opened this issue Sep 28, 2021 · 1 comment

Comments

@dlwlgus53
Copy link

After I download the pretrained model, I fond'config.json, weights.th and vocabulary folder. However,

tokenizer = BertModel.from_pretrained('bert-base-uncased')
model = BertModel.from_pretrained("bert-base-uncased")
device = torch.device(f'cuda:{args.gpu_number}' if torch.cuda.is_available() else 'cpu')
torch.cuda.set_device(device) # change allocation of current GPU

print("\n\nuse trained model")
model.load_state_dict(torch.load('weights.th',map_location='cuda:0'))
print("no error!")

this doesn't work. How can I load pre-trained model??

@dlwlgus53 dlwlgus53 changed the title How can I pretrained model? How can I load pretrained model? Sep 28, 2021
@lucadiliello
Copy link

Hi, I rewrote the script to train of every MRQA dataset which is compatible with any type of transformer model on any hardware. https://github.com/lucadiliello/mrqa-lightning

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

2 participants