def test_embed_mixture():
 em = EmbedMixture(10, 2, 5, dropout_ratio=0.0)
 doc_ids = Variable(np.arange(1, dtype='int32'))
 doc_vector = em(doc_ids).data
 weights = softmax(em.weights.W.data[0, :])
 un_weights = softmax(em.unnormalized_weights(doc_ids).data[0, :])
 test = np.sum((weights * em.factors.W.data.T), axis=1)
 assert np.allclose(doc_vector, test)
 assert np.allclose(un_weights, weights)

def test_embed_mixture ( ) : em = EmbedMixture ( 10 , 2 , 5 , dropout_ratio = 0.0 ) doc_ids = Variable ( np . arange ( 1 , dtype = 'int32' ) ) doc_vector = em ( doc_ids ) . data weights = softmax ( em . weights . W . data [ 0 , : ] ) un_weights = softmax ( em . unnormalized_weights ( doc_ids ) . data [ 0 , : ] ) test = np . sum ( ( weights * em . factors . W . data . T ) , axis = 1 ) assert np . allclose ( doc_vector , test ) assert np . allclose ( un_weights , weights )
manually test the projection logic between topic weights and vectors .