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

Reading the model into BERT? #22

Open
klangborg opened this issue Nov 29, 2021 · 0 comments
Open

Reading the model into BERT? #22

klangborg opened this issue Nov 29, 2021 · 0 comments

Comments

@klangborg
Copy link

I have an issue reading the model into BERT.

Can you share a piece of sample code on how to do that, or maybe have a look at what I am doing wrong?

This is my code:

tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
config = BertConfig.from_json_file('dk/config.json')
model = BertForMaskedLM.from_pretrained(pretrained_model_name_or_path='dk/bert_model.ckpt.index', from_tf=True,config=config)

I get this error on the last line of the code above

 File "blanks.py", line 8, in <module>
    model = BertForMaskedLM.from_pretrained(pretrained_model_name_or_path='dk/bert_model.ckpt.index', from_tf=True,config=config)    
  File "\AppData\Local\Programs\Python\Python36\lib\site-packages\transformers\modeling_utils.py", line 1423, in from_pretrained
    model = cls.load_tf_weights(model, config, resolved_archive_file[:-6])  # Remove the '.index'
  File "AppData\Local\Programs\Python\Python36\lib\site-packages\transformers\models\bert\modeling_bert.py", line 156, 
in load_tf_weights_in_bert
    if pointer.shape != array.shape:
AttributeError: 'NoneType' object has no attribute 'shape'

Best regards
Kristian

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