Getting TypeError: unhashable type: 'list'
and AttributeError: dlsym(0x7fa8c57be020, AttachDebuggerTracing): symbol not found
errors when I create my model based on Word2Vec
implementation of the gensim
module.
Each entry has three parts which are presented within a list. And, the model contains three entries for the sake of demonstration.
Here is what I have tried:
model = Word2Vec(sentences=features, size=100, sg=1, window=3, min_count=1, iter=10, workers=Pool()._processes)
model.build_vocab(features)
model.train(features)
The value of the features
is:
[
[
['permission.ACCESS_WIFI_STATE', 'permission.ACCESS_NETWORK_STATE', 'permission.READ_PHONE_STATE', 'permission.INTERNET', 'permission.CHANGE_WIFI_STATE'],
['intent.action.MAIN', 'intent.action.BATTERY_CHANGED_ACTION', 'intent.action.SIG_STR', 'intent.action.BOOT_COMPLETED'],
[]
],
[
['permission.WRITE_EXTERNAL_STORAGE', 'permission.ACCESS_NETWORK_STATE', 'permission.READ_PHONE_STATE', 'permission.INTERNET', 'permission.INSTALL_PACKAGES', 'permission.SEND_SMS', 'permission.DELETE_PACKAGES'],
['intent.action.BOOT_COMPLETED', 'intent.action.USER_PRESENT', 'intent.action.PHONE_STATE', 'intent.action.MAIN'],
[]
],
[
['permission.WRITE_EXTERNAL_STORAGE', 'permission.ACCESS_FINE_LOCATION', 'permission.INTERNET', 'permission.READ_PHONE_STATE', 'permission.ACCESS_COARSE_LOCATION', 'permission.CALL_PHONE', 'permission.READ_CONTACTS', 'permission.READ_SMS'],
['intent.action.PHONE_STATE', 'intent.action.MAIN'],
[]
]
]
Edit: The error stack trace after correcting the form of the feature vector according to the comment of @gojomo.
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py", line 1631, in settrace
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py", line 1631, in settrace
2019-12-13 12:24:34,519:gensim.models.base_any2vec:INFO - worker thread finished; awaiting finish of 3 more threads
2019-12-13 12:24:34,519:gensim.models.base_any2vec:INFO - worker thread finished; awaiting finish of 2 more threads
2019-12-13 12:24:34,519:gensim.models.base_any2vec:INFO - worker thread finished; awaiting finish of 1 more threads
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py", line 1631, in settrace
2019-12-13 12:24:34,519:gensim.models.base_any2vec:INFO - worker thread finished; awaiting finish of 0 more threads
2019-12-13 12:24:34,520:gensim.models.base_any2vec:INFO - EPOCH - 10 : training on 6 raw words (0 effective words) took 0.0s, 0 effective words/s
stop_at_frame,
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py", line 1711, in _locked_settrace
2019-12-13 12:24:34,520:gensim.models.base_any2vec:INFO - training on a 60 raw words (2 effective words) took 0.1s, 21 effective words/s
stop_at_frame,
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py", line 1711, in _locked_settrace
2019-12-13 12:24:34,520:gensim.models.base_any2vec:WARNING - under 10 jobs per worker: consider setting a smaller `batch_words' for smoother alpha decay
stop_at_frame,
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py", line 1711, in _locked_settrace
debugger.enable_tracing(apply_to_all_threads=True)
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py", line 482, in enable_tracing
debugger.enable_tracing(apply_to_all_threads=True)
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py", line 482, in enable_tracing
pydevd_tracing.set_trace_to_threads(self.dummy_trace_dispatch)
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd_tracing.py", line 241, in set_trace_to_threads
2019-12-13 12:24:34,521:gensim.utils:INFO - saving Word2Vec object under model/word2vec_model, separately None
pydevd_tracing.set_trace_to_threads(self.dummy_trace_dispatch)
debugger.enable_tracing(apply_to_all_threads=True) File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd_tracing.py", line 241, in set_trace_to_threads
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py", line 482, in enable_tracing
pydevd_tracing.set_trace_to_threads(self.dummy_trace_dispatch)
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd_tracing.py", line 241, in set_trace_to_threads
result = lib.AttachDebuggerTracing(
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/ctypes/__init__.py", line 361, in __getattr__
result = lib.AttachDebuggerTracing(
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/ctypes/__init__.py", line 361, in __getattr__
result = lib.AttachDebuggerTracing(
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/ctypes/__init__.py", line 361, in __getattr__
2019-12-13 12:24:34,521:gensim.utils:INFO - not storing attribute vectors_norm
func = self.__getitem__(name)func = self.__getitem__(name)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/ctypes/__init__.py", line 366, in __getitem__
func = self.__getitem__(name)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/ctypes/__init__.py", line 366, in __getitem__
2019-12-13 12:24:34,522:gensim.utils:INFO - not storing attribute cum_table
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/ctypes/__init__.py", line 366, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
func = self._FuncPtr((name_or_ordinal, self))AttributeError: dlsym(0x7fed18f247e0, AttachDebuggerTracing): symbol not found
AttributeError: dlsym(0x7fed18f247e0, AttachDebuggerTracing): symbol not found
func = self._FuncPtr((name_or_ordinal, self))
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py", line 1631, in settrace
AttributeError: dlsym(0x7fed18d2ff70, AttachDebuggerTracing): symbol not found
stop_at_frame,
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py", line 1711, in _locked_settrace
2019-12-13 12:24:34,524:gensim.utils:INFO - saved model/word2vec_model
debugger.enable_tracing(apply_to_all_threads=True)
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py", line 482, in enable_tracing
pydevd_tracing.set_trace_to_threads(self.dummy_trace_dispatch)
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd_tracing.py", line 241, in set_trace_to_threads
result = lib.AttachDebuggerTracing(
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/ctypes/__init__.py", line 361, in __getattr__
func = self.__getitem__(name)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/ctypes/__init__.py", line 366, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: dlsym(0x7fed18a163b0, AttachDebuggerTracing): symbol not found
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py", line 1631, in settrace
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py", line 1631, in settrace
stop_at_frame,
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py", line 1711, in _locked_settrace
stop_at_frame,
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py", line 1711, in _locked_settrace
debugger.enable_tracing(apply_to_all_threads=True)
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py", line 482, in enable_tracing
debugger.enable_tracing(apply_to_all_threads=True)
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py", line 482, in enable_tracing
pydevd_tracing.set_trace_to_threads(self.dummy_trace_dispatch)
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd_tracing.py", line 241, in set_trace_to_threads
pydevd_tracing.set_trace_to_threads(self.dummy_trace_dispatch)
result = lib.AttachDebuggerTracing( File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd_tracing.py", line 241, in set_trace_to_threads
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/ctypes/__init__.py", line 361, in __getattr__
result = lib.AttachDebuggerTracing(
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/ctypes/__init__.py", line 361, in __getattr__
func = self.__getitem__(name)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/ctypes/__init__.py", line 366, in __getitem__
func = self.__getitem__(name)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/ctypes/__init__.py", line 366, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: dlsym(0x7fed15fd5850, AttachDebuggerTracing): symbol not found
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: dlsym(0x7fed18a163b0, AttachDebuggerTracing): symbol not found
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py", line 1631, in settrace
stop_at_frame,
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py", line 1711, in _locked_settrace
debugger.enable_tracing(apply_to_all_threads=True)
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py", line 482, in enable_tracing
pydevd_tracing.set_trace_to_threads(self.dummy_trace_dispatch)
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd_tracing.py", line 241, in set_trace_to_threads
result = lib.AttachDebuggerTracing(
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/ctypes/__init__.py", line 361, in __getattr__
func = self.__getitem__(name)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/ctypes/__init__.py", line 366, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: dlsym(0x7fed18b09320, AttachDebuggerTracing): symbol not found
Traceback (most recent call last):
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py", line 1631, in settrace
stop_at_frame,
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py", line 1711, in _locked_settrace
debugger.enable_tracing(apply_to_all_threads=True)
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd.py", line 482, in enable_tracing
pydevd_tracing.set_trace_to_threads(self.dummy_trace_dispatch)
File "/Applications/PyCharm.app/Contents/plugins/python/helpers/pydev/pydevd_tracing.py", line 241, in set_trace_to_threads
result = lib.AttachDebuggerTracing(
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/ctypes/__init__.py", line 361, in __getattr__
func = self.__getitem__(name)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/ctypes/__init__.py", line 366, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: dlsym(0x7fed15fd5850, AttachDebuggerTracing): symbol not found
Gensim's Word2Vec
expects its corpus sentences
to be a sequence where each individual item is a list of string tokens. (That is, those string tokens are words.)
Instead, you have a list (which is acceptable as a sequence), where each of its items is a list (which is also acceptable), but then each of those lists instead has as each item yet another list – when for Word2Vec
training, each of those items should be a string token (word).
(I've edited your example data to be be structurally-indented, to make the levels of nesting clearer.)
If those innermost lists-of-strings are your real individual "sentences", you need to be sure they're the items in your outermost list.
(If, on the other hand, you really want a cluster like ['intent.action.PHONE_STATE', 'intent.action.MAIN']
to be a single "word" in your model, you'll want to change that list into a single string token, so it can look like a word – and thus hashable key – to Word2Vec
and Python.)