similarity_matrix = w2v_model.similarity_matrix(dictionary). The error I got was AttributeError: 'KeyedVectors' object has no attribute 'similarity_matrix'. I couldn't find references to similarity_matrix in the docs, but could be wrong. Anyone better versed can help me?
FastText- infer vector for each word and calculate vector of document as average of word-vectors
from gensim.corpora import Dictionary from gensim.models import LsiModel data = [["a", "a", "b"], ["c", "d"]] dictionary = Dictionary(data) corpus = [dictionary.doc2bow(doc) for doc in data] model = LsiModel(corpus, id2word=dictionary) list(model[corpus]) # [[(0, 2.236067977499789)], [(1, -1.4142135623730951)]]
dictionary = Dictionary(docs) corpus = [ dictionary.doc2bow(doc) for doc in docs ] model = LsiModel(corpus, id2word=dictionary, num_topics =10) for doc in docs: if len(doc) ==0: print("doc: ",doc) vecs =  for doc in list(model[corpus]): x = [ vec for vec in doc ] if len(x) == 0: print("vec: ", x) vecs.append(x) vecs = np.array(vecs, float)
vec:  vec:  vec:  vec: 
full2sparcefunction https://github.com/RaRe-Technologies/gensim/blob/develop/gensim/models/lsimodel.py#L486 (but believe me, you do not need it, these values are filtered for a reason, too small values like a noize, this doesn't contain any useful information).