from tensorflow.contrib.learn.python.learn import ops

      self.assertEqual(prediction.get_shape()[1], 2)
      self.assertEqual(loss.get_shape(), [])
      value = session.run(loss, {features: [[0.2, 0.3, 0.2]], labels: [[0, 1]]})
      self.assertAllClose(value, 0.55180627)

  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)

  def test_categorical_variable(self):
    random_seed.set_random_seed(42)
    with self.cached_session() as sess:
      cat_var_idx = array_ops.placeholder(dtypes.int64, [2, 2])
      embeddings = ops.categorical_variable(
          cat_var_idx, n_classes=5, embedding_size=10, name="my_cat_var")
      sess.run(variables.global_variables_initializer())
      emb1 = sess.run(embeddings,
                      feed_dict={cat_var_idx.name: [[0, 1], [2, 3]]})
