def test_embed():
 embed_dense = L.EmbedID(5, 10)
 embed_sparse = L.EmbedID(5, 10)
 embed_dense.W.data[:] = np.random.randn(5, 10).astype('float32')
 embed_sparse.W.data[:] = np.random.randn(5, 10).astype('float32')
 embed_sparse.W.data[:, 1:] /= 100000.0
 dhl_dense_01 = dirichlet_likelihood(embed_dense, alpha=0.1).data
 dhl_sparse_01 = dirichlet_likelihood(embed_sparse, alpha=0.1).data
 msg = 'Sparse vector has higher likelihood than dense with alpha=0.1'
 assert (dhl_sparse_01 > dhl_dense_01), msg

def test_embed ( ) : embed_dense = L . EmbedID ( 5 , 10 ) embed_sparse = L . EmbedID ( 5 , 10 ) embed_dense . W . data [ : ] = np . random . randn ( 5 , 10 ) . astype ( 'float32' ) embed_sparse . W . data [ : ] = np . random . randn ( 5 , 10 ) . astype ( 'float32' ) embed_sparse . W . data [ : , 1 : ] /= 100000.0 dhl_dense_01 = dirichlet_likelihood ( embed_dense , alpha = 0.1 ) . data dhl_sparse_01 = dirichlet_likelihood ( embed_sparse , alpha = 0.1 ) . data msg = 'Sparse vector has higher likelihood than dense with alpha=0.1' assert ( dhl_sparse_01 > dhl_dense_01 ) , msg
test that embedding is treated like a variable .