#NEWLINE# def testTrainingCbow( self ) : #NEWLINE# #INDENT# 'Test CBOW word2vec training.' #NEWLINE# model = word2vec . Word2Vec ( size = 2 , min_count = 1 , sg = 0 ) #NEWLINE# model . build_vocab ( sentences ) #NEWLINE# self . assertTrue ( ( model . syn0 . shape == ( len ( model . vocab ) , 2 ) ) ) #NEWLINE# self . assertTrue ( ( model . syn1 . shape == ( len ( model . vocab ) , 2 ) ) ) #NEWLINE# model . train ( sentences ) #NEWLINE# sims = model . most_similar ( 'graph' , topn = 10 ) #NEWLINE# graph_vector = model . syn0norm [ model . vocab [ 'graph' ] . index ] #NEWLINE# sims2 = model . most_similar ( positive = [ graph_vector ] , topn = 11 ) #NEWLINE# self . assertEqual ( sims , sims2 [ 1 : ] ) #NEWLINE# model2 = word2vec . Word2Vec ( sentences , size = 2 , min_count = 1 , sg = 0 ) #NEWLINE# self . models_equal ( model , model2 )