Discussion:
[gensim:11801] assert self.projection.u is not None, "decomposition not initialized yet"
g***@case.edu
2018-11-23 21:46:03 UTC
Permalink
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'
--
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.
g***@case.edu
2018-11-23 22:30:06 UTC
Permalink
I have edited my question:


I aim to implement lsa similarity based on wikipedia to find the similarity
Post by g***@case.edu
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 help is appreciated.
# 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)
docs_bow = (id2word.doc2bow(tokenize(document)) for document in
index_documents)
docs_tfidf = tfidf_model[docs_bow]
docs_lsi = lsi_model[docs_tfidf]
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.
Alistair Windsor
2018-11-25 14:43:52 UTC
Permalink
How are index_documents defined? NoneType' object has no attribute errors
often arise when you pass in an empty object,

Yours,

Alistair
Post by g***@case.edu
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)
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.
Loading...