lstm-char-cnn-tensorflow icon indicating copy to clipboard operation
lstm-char-cnn-tensorflow copied to clipboard

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

Open jingweimo opened this issue 7 years ago • 5 comments

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)

jingweimo avatar Jun 24 '17 00:06 jingweimo

@jingweimo

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

azainab avatar Aug 07 '17 10:08 azainab

use contains instead

WangYongzhao avatar Sep 10 '17 14:09 WangYongzhao

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

labro avatar Sep 20 '17 13:09 labro

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

hrandiac avatar Dec 30 '17 23:12 hrandiac

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

405560984 avatar Mar 18 '19 16:03 405560984