Hossein
Hossein

Reputation: 2111

HuggingFace 'TFEmbeddings' object has no attribute 'word_embeddings'

Trying to run this TextualHeatmap example, we encounter 'TFEmbeddings' object has no attribute 'word_embeddings' error in the following code snippet from the HuggingFace transformers library. Any help is appreciated.

from transformers import TFDistilBertForMaskedLM, DistilBertTokenizer 
dbert_model = TFDistilBertForMaskedLM.from_pretrained('distilbert-base-uncased') 
dbert_tokenizer = DistilBertTokenizer.from_pretrained('distilbert-base-uncased') 
dbert_embmat = dbert_model.distilbert.embeddings.word_embeddings

Upvotes: 0

Views: 2616

Answers (2)

Pushpendu Ghosh
Pushpendu Ghosh

Reputation: 105

Downgrading the version of transformers will work.

pip install transformers==3.1.0

Upvotes: 0

taichi_tiger
taichi_tiger

Reputation: 1071

Try to use '.weight' instead of '.word_embeddings' as per hugging face latest implementation. It works for me.

Upvotes: 1

Related Questions