zhuchen03 / FreeLB

Adversarial Training for Natural Language Understanding
250 stars 41 forks source link

'AlbertForSequenceClassification' object has no attribute 'encoder' #3

Closed trueto closed 4 years ago

trueto commented 4 years ago

hi, when i used the example from huggingface-transformers/examples/run_glue_freelb.py i met the error as this 'AlbertForSequenceClassification' object has no attribute 'encoder' it seems the code

if isinstance(model, torch.nn.DataParallel):
        embeds_init = model.module.encoder.embeddings.word_embeddings(batch[0])
else:
        embeds_init = model.encoder.embeddings.word_embeddings(batch[0])

can not work!

zhuchen03 commented 4 years ago

Did you run pip install --editable . under huggingface-transformers?

trueto commented 4 years ago

Did you run pip install --editable . under huggingface-transformers?

thanks for reply, i have fixed it!