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

missing 1 required positional argument: 'num_classes' in 'from_pretrained' #833

Closed
desireevl opened this issue Jul 19, 2019 · 3 comments
Closed

Comments

@desireevl
Copy link
Contributor

I am running a multiclass BERT classification model and am receiving the following error:

Traceback (most recent call last): File "train_bert_multi_label.py", line 144, in <module> main() File "train_bert_multi_label.py", line 78, in main num_classes = len(id2label)) File "/opt/miniconda3/envs/tempenv/lib/python3.6/site-packages/pytorch_transformers/modeling_utils.py", line 403, in from_pretrained model = cls(config) TypeError: __init__() missing 1 required positional argument: 'num_classes'

The script worked fine when using pytorch-pretrained-bert and am guessing there is an issue from the new release.

Thanks for the great tools :)

@thomwolf
Copy link
Member

Yes, @xanlsh is working on an update to reduce the effect of this breaking change in #866.

You should be able to keep your script unchanged.

@anlsh
Copy link

anlsh commented Jul 26, 2019

@desireevl Since #866 has been merged, your code should work now

@desireevl
Copy link
Contributor Author

Thanks!

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