roatienza / Deep-Learning-Experiments

Videos, notes and experiments to understand deep learning
MIT License
1.1k stars 760 forks source link

rnn_words.py: unhashable type: 'list' #6

Closed bpodq closed 6 years ago

bpodq commented 7 years ago

Loaded training data... Traceback (most recent call last): File "rnn_words.py", line 56, in dictionary, reverse_dictionary = build_dataset(training_data) File "rnn_words.py", line 49, in build_dataset count = collections.Counter(words).most_common() File "/usr/lib64/python2.7/collections.py", line 444, in init self.update(iterable, **kwds) File "/usr/lib64/python2.7/collections.py", line 526, in update self[elem] = self_get(elem, 0) + 1 TypeError: unhashable type: 'list'

I searched the web but do not solve it, anyone can help me?

roatienza commented 6 years ago

I think this might be python2.7 specific. The code has been tested on python3 only.

Rick-McCoy commented 6 years ago

Loaded training data...
Traceback (most recent call last): File "D:\Machine_Learning\LSTM\Tensorflow CNN-LSTM Model\SampleTextLSTM.py", line 59, in dictionary, reverse_dictionary = build_dataset(training_data) File "D:\Machine_Learning\LSTM\Tensorflow CNN-LSTM Model\SampleTextLSTM.py", line 52, in build_dataset count = collections.Counter(words).most_common() File "C:\Users\julia\AppData\Local\Programs\Python\Python36\lib\collections__init.py", line 537, in init self.update(*args, **kwds) File "C:\Users\julia\AppData\Local\Programs\Python\Python36\lib\collections\init__.py", line 624, in update _count_elements(self, iterable) TypeError: unhashable type: 'list'

Running python 3.6.2, same thing happening here.

Shivakishore14 commented 6 years ago

I had the same Issue, I fixed it by changing line 42

content = np.reshape(content, [-1, ]) to content = np.hstack(content)