carpedm20 / lstm-char-cnn-tensorflow

in progress
MIT License
761 stars 243 forks source link

AttributeError: 'dict' object has no attribute 'has_key' #22

Open jingweimo opened 7 years ago

jingweimo commented 7 years ago

I use anaconda with python3.5 and tensorflow 1.2 in win10. Running the example codes: python main.py --dataset ptb and python main.py --dataset ptb --forward_only_True both give the same error message.

Traceback shows there may be something wrong with: if not word2idx.has_key(word): in batch_loader.py (line 144)

azainab commented 7 years ago

@jingweimo

Did you get a solution to this? I am facing the same issue.

WangYongzhao commented 7 years ago

use contains instead

labro commented 7 years ago

in python 3.5 the method has_key has been removed. Maybe you could try python2.7

hrandiac commented 6 years ago

I get an AttributeError: 'dict' object has no attribute 'has_key' in python 2.7

405560984 commented 5 years ago

you must use "if key in cdist:", cdist is your data name