Couldn't import '''BertPreTrainedModel'''
I installed this lib by '''pip install pytorch-pretrained-bert''', and there are no problems when run the examples. However, when I import '''BertPreTrainedModel''', I use '''from pytorch_pretrained_bert import BertPreTrainedModel''', error occurs.
I want to write a new class like '''BertForSequenceClassification''', and in order to use the facility of constructing the instance of the class by "'from_pretrained('bert-base-uncased')''' . My new class need to inherit the class '''BertPreTrainedModel'''.
In another way, we need the config file to get the instance of the class like '''BertForSequenceClassification''', however, I couldn't find the file 'bert_config.json'.
Are there other ways to write a new class like '''BertForSequenceClassification'''?
Thanks all of you!
I guess you have to clone the repository. You just need to add all the classes you want to import in this line:
https://github.com/huggingface/pytorch-pretrained-BERT/blob/3fc63f126ddf883ba9659f13ec046c3639db7b7e/pytorch_pretrained_bert/__init__.py#L12
Then you can install from source:
`pip install --editable .`

Of course since you download all the code, you can directly add your own class in `/pytorch_pretrained_bert/modeling_openai.py` then install from source.<|||||>So sorry that I am not familiar with the lib installation in python. 
Thanks for your suggestions. I know how to solve it.

On 2019-05-20 19:32, eveliao wrote:
> I guess you have to clone the repository. You just need to add all the
> classes you want to import in this line:
> https://github.com/huggingface/pytorch-pretrained-BERT/blob/3fc63f126ddf883ba9659f13ec046c3639db7b7e/pytorch_pretrained_bert/__init__.py#L12
> [1]
> Then you can install from source:
> pip install --editable .
> 
> Of course since you download all the code, you can directly add your
> own class in /pytorch_pretrained_bert/modeling_openai.py then install
> from source.
> 
> --
> You are receiving this because you authored the thread.
> Reply to this email directly, view it on GitHub [2], or mute the
> thread [3]. [ { "@context": "http://schema.org", "@type":
> "EmailMessage", "potentialAction": { "@type": "ViewAction", "target":
> "https://github.com/huggingface/pytorch-pretrained-BERT/issues/615?email_source=notifications\u0026email_token=AFUNK24OFCY7KRHX6OVL4PTPWKD3BA5CNFSM4HNTFW5KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVYQ2OA#issuecomment-493948216",
> "url":
> "https://github.com/huggingface/pytorch-pretrained-BERT/issues/615?email_source=notifications\u0026email_token=AFUNK24OFCY7KRHX6OVL4PTPWKD3BA5CNFSM4HNTFW5KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVYQ2OA#issuecomment-493948216",
> "name": "View Issue" }, "description": "View this Issue on GitHub",
> "publisher": { "@type": "Organization", "name": "GitHub", "url":
> "https://github.com" } } ]
> 
> Links:
> ------
> [1]
> https://github.com/huggingface/pytorch-pretrained-BERT/blob/3fc63f126ddf883ba9659f13ec046c3639db7b7e/pytorch_pretrained_bert/__init__.py#L12
> [2]
> https://github.com/huggingface/pytorch-pretrained-BERT/issues/615?email_source=notifications&amp;email_token=AFUNK24OFCY7KRHX6OVL4PTPWKD3BA5CNFSM4HNTFW5KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODVYQ2OA#issuecomment-493948216
> [3]
> https://github.com/notifications/unsubscribe-auth/AFUNK24OKPGO4TJTYJ7SPZ3PWKD3BANCNFSM4HNTFW5A

<|||||>This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
