def learn_embeddings(self, output, output_format='binary'):
"""
Learn embeddings by optimizing the Skipgram objective using SGD.
"""
self._simulate_walks() # simulate random walks
model = Word2Vec(self._walks, size=self.dimensions, window=self.window_size, min_count=0,
workers=self.workers, iter=self.iter, negative=25, sg=1)
print("defined model using w2v")
is_binary = output_format != 'text'
model.wv.save_word2vec_format(output, binary=is_binary)
actual_format = 'text' if output_format == 'text' else 'binary'
print("saved model in word2vec %s format" % actual_format)
return
评论列表
文章目录