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

Weights not initialized from pretrained model #180

Closed
lemonhu opened this issue Jan 11, 2019 · 3 comments
Closed

Weights not initialized from pretrained model #180

lemonhu opened this issue Jan 11, 2019 · 3 comments

Comments

@lemonhu
Copy link

lemonhu commented Jan 11, 2019

Thanks for your awesome work!

When I execute the following code for a named entity recognition tasks:
model = BertForTokenClassification.from_pretrained("bert-base-uncased", num_labels=num_labels)

Output the following information:

Weights of BertForTokenClassification not initialized from pretrained model: ['classifier.weight', 'classifier.bias']
Weights from pretrained model not used in BertForTokenClassification: ['cls.predictions.bias', 'cls.predictions.transform.dense.weight', 'cls.predictions.transform.dense.bias', 'cls.predictions.decoder.weight', 'cls.seq_relationship.weight', 'cls.seq_relationship.bias', 'cls.predictions.transform.LayerNorm.weight', 'cls.predictions.transform.LayerNorm.bias']

What puzzles me is that the parameters of the classifier are not initialized.

@rodgzilla
Copy link
Contributor

rodgzilla commented Jan 11, 2019

Hi!

Those messages are correct, the pretrained weights that have been released by Google Brain are just the ones of the core network. They did not release task specific weights. To get a model that solves a specific classification task, you would have to train one yourself or get it from someone else.

@thomwolf There have been multiple issues about this specific behavior, maybe we should add some kind of text either as a print while loading the model or in the documentation. I would be happy to do it. What would you prefer?

@lemonhu
Copy link
Author

lemonhu commented Jan 11, 2019

Oh, I see, I will train the model with my own dataset, thank you for your answer.

@thomwolf
Copy link
Member

Yes you are right @rodgzilla we should detail a bit the messages in modeling.py to say that These weights will be trained from scratch.

ZYC-ModelCloud pushed a commit to ZYC-ModelCloud/transformers that referenced this issue Nov 14, 2024
Co-authored-by: LRL-ModelCloud <lrl@modelcloud.ai>
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

3 participants