transformers icon indicating copy to clipboard operation
transformers copied to clipboard

weights initialized two times

Open friskit-china opened this issue 7 years ago • 2 comments

Hi,

I found that you initilized all weights twice:

The first one is in BertModel class:

https://github.com/huggingface/pytorch-pretrained-BERT/blob/3ba5470eb85464df62f324bea88e20da234c423f/pytorch_pretrained_bert/modeling.py#L586

And the second one is in classes of each tasks such as in BertForSequenceClassification class:

https://github.com/huggingface/pytorch-pretrained-BERT/blob/3ba5470eb85464df62f324bea88e20da234c423f/pytorch_pretrained_bert/modeling.py#L674

I think maybe you only need the second one?

friskit-china avatar Dec 09 '18 07:12 friskit-china

I think it required for both the places. Because both of them can be used individually. As it is mentioned in the README.md file, the model can be loaded with 7 classes. In fact if you check BertForMaskedLM and BertForNextSentencePrediction classes it also has the weights initialised.

Please correct me if I am wrong :)

Arjunsankarlal avatar Dec 09 '18 07:12 Arjunsankarlal

You are right @Arjunsankarlal :-)

thomwolf avatar Dec 09 '18 21:12 thomwolf