jjzjj

sentenceTokens

全部标签

python - 类型错误 : ufunc 'add' did not contain a loop with signature matching types

我正在创建句子的词袋表示。然后将句子中存在的单词与文件“vectors.txt”进行比较,以获得它们的嵌入向量。在获得句子中存在的每个单词的向量后,我将取句子中单词向量的平均值。这是我的代码:importnltkimportnumpyasnpfromnltkimportFreqDistfromnltk.corpusimportbrownnews=brown.words(categories='news')news_sents=brown.sents(categories='news')fdist=FreqDist(w.lower()forwinnews)vocabulary=[word

python - 类型错误 : ufunc 'add' did not contain a loop with signature matching types

我正在创建句子的词袋表示。然后将句子中存在的单词与文件“vectors.txt”进行比较,以获得它们的嵌入向量。在获得句子中存在的每个单词的向量后,我将取句子中单词向量的平均值。这是我的代码:importnltkimportnumpyasnpfromnltkimportFreqDistfromnltk.corpusimportbrownnews=brown.words(categories='news')news_sents=brown.sents(categories='news')fdist=FreqDist(w.lower()forwinnews)vocabulary=[word