def test_embedding_lookup(self): d_embed = 5 n_embed = 10 ids_shape = (2, 3, 4) embeds = np.random.randn(n_embed, d_embed) ids = np.random.randint(0, n_embed, ids_shape) with self.test_session(): embed_np = embeds[ids] embed_tf = ops.embedding_lookup(embeds, ids).eval() self.assertEqual(embed_np.shape, embed_tf.shape) self.assertAllClose(embed_np, embed_tf)
def test_embedding_lookup(self): d_embed = 5 n_embed = 10 ids_shape = (2, 3, 4) embeds = np.random.randn(n_embed, d_embed) ids = np.random.randint(0, n_embed, ids_shape) with self.cached_session(): embed_np = embeds[ids] embed_tf = ops.embedding_lookup(embeds, ids).eval() self.assertEqual(embed_np.shape, embed_tf.shape) self.assertAllClose(embed_np, embed_tf)