【发布时间】:2021-12-17 15:43:22
【问题描述】:
我现在正在试验肽序列和 NLP,并尝试使用 word2vec 嵌入肽序列。
肽段采用长字符串格式(例如:'KCNTATCATQRLANFLVRSSNNLGPVLPPTNVGSNTY'),因此我将肽段序列拆分为三元组。但是当我尝试嵌入它们时,我不断收到此错误:TypeError: unhashable type:'list.'
不确定如何解决此错误,因为我不太明白为什么会出现此错误。我的代码链接here,这是完整的错误输出:
TypeError Traceback (most recent call last)
<ipython-input-17-966c68819734> in <module>()
6
7 # embeddings pos
----> 8 w2vpos = Word2Vec(kmersdatapos, size=EMB_DIM,window=5,min_count=5,negative=15,iter=10,workers=multiprocessing.cpu_count())
4 frames
/usr/local/lib/python3.7/dist-packages/gensim/models/word2vec.py in _scan_vocab(self, sentences, progress_per, trim_rule)
1553 )
1554 for word in sentence:
-> 1555 vocab[word] += 1
1556 total_words += len(sentence)
1557
TypeError: unhashable type: 'list'
欢迎提出任何建议!
【问题讨论】:
标签: python nlp bioinformatics gensim word2vec