g***@case.edu
2018-11-23 21:46:03 UTC
I aim to implement lsa similarity based on wikipedia to find the similarity
among my questions and answers. I wrote the coed below but it gives me this
error recently when I started run it on hpc. Any helpis appreciated. I get
the error after constructing some of the wiki_index.1, wiki_index.2,
wiki_index.3 ...
# load the corpora created in the previous notebook
tfidf_corpus = gensim.corpora.MmCorpus('./data/wiki_tfidf.mm')
lsi_corpus = gensim.corpora.MmCorpus('./data/wiki_lsa.mm')
#print(tfidf_corpus)
#print(lsi_corpus)
# load the models too
id2word_wiki = gensim.corpora.Dictionary.load('./data/wiki.dictionary')
#lda_model = gensim.models.LdaModel.load('./data/lda_wiki.model')
tfidf_model = gensim.models.TfidfModel.load('./data/tfidf_wiki.model')
lsi_model = gensim.models.LsiModel.load('./data/lsi_wiki.model')
index = Similarity('./data/wiki_index', lsi_corpus,
num_features=lsi_corpus.num_terms)
#print(index)
# store to disk
index.save('./data/wiki_index.index')
# load back = same index
index = Similarity.load('./data/wiki_index.index')
#print(index)
error:
File "lsa-final1.py", line 226, in <module>
docs_lsi = lsi_model[docs_tfidf]
File
"/root/anaconda3/envs/my_env/lib/python3.7/site-packages/gensim/models/lsimodel.py",
line 564, in __getitem__
assert self.projection.u is not None, "decomposition not initialized
yet"
AttributeError: 'NoneType' object has no attribute 'u'
among my questions and answers. I wrote the coed below but it gives me this
error recently when I started run it on hpc. Any helpis appreciated. I get
the error after constructing some of the wiki_index.1, wiki_index.2,
wiki_index.3 ...
# load the corpora created in the previous notebook
tfidf_corpus = gensim.corpora.MmCorpus('./data/wiki_tfidf.mm')
lsi_corpus = gensim.corpora.MmCorpus('./data/wiki_lsa.mm')
#print(tfidf_corpus)
#print(lsi_corpus)
# load the models too
id2word_wiki = gensim.corpora.Dictionary.load('./data/wiki.dictionary')
#lda_model = gensim.models.LdaModel.load('./data/lda_wiki.model')
tfidf_model = gensim.models.TfidfModel.load('./data/tfidf_wiki.model')
lsi_model = gensim.models.LsiModel.load('./data/lsi_wiki.model')
index = Similarity('./data/wiki_index', lsi_corpus,
num_features=lsi_corpus.num_terms)
#print(index)
# store to disk
index.save('./data/wiki_index.index')
# load back = same index
index = Similarity.load('./data/wiki_index.index')
#print(index)
error:
File "lsa-final1.py", line 226, in <module>
docs_lsi = lsi_model[docs_tfidf]
File
"/root/anaconda3/envs/my_env/lib/python3.7/site-packages/gensim/models/lsimodel.py",
line 564, in __getitem__
assert self.projection.u is not None, "decomposition not initialized
yet"
AttributeError: 'NoneType' object has no attribute 'u'
--
You received this message because you are subscribed to the Google Groups "Gensim" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gensim+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Gensim" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gensim+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.