Skip to content

Loading fine tuned BertForMaskedLM #215

@tgriseau

Description

@tgriseau

Hi,

I tried to fine tune BertForMaskedLM and it works. But i'm facing issues when I try to load the fine tuned model.
Here is the code I used to load the model :

model_state_dict = torch.load("./finetunedmodel/pytorch_model.bin",  map_location='cpu')
model_fine = BertForMaskedLM.from_pretrained(pretrained_model_name='bert-base-multilingual-cased', state_dict=model_state_dict, cache_dir='./data')

The error I'm facing is : init() got an unexpected keyword argument 'state_dict'

Does someone already faced this issue ?

Thanks

Edit : I trained my model on gpu and try to use it on cpu. When I use it on gpu it works !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions