コード例 #1
0
ファイル: test_ops.py プロジェクト: 0-T-0/tensorflow
 def test_one_hot_matrix(self):
   with self.test_session() as sess:
     tensor_in = tf.placeholder(tf.int64, [10, 2])
     one_hot_tensor = ops.one_hot_matrix(tensor_in, 3)
     res = sess.run(ops.one_hot_matrix([[0, 1], [2, 1]], 3))
   self.assertAllEqual(one_hot_tensor.get_shape(), [10, 2, 3])
   self.assertAllEqual(res, [[[1.0, 0, 0], [0, 1.0, 0]],
                             [[0, 0, 1.0], [0, 1.0, 0]]])
コード例 #2
0
ファイル: ops_test.py プロジェクト: HowieYang0/notmnist-ex
 def test_one_hot_matrix(self):
     with self.test_session() as sess:
         tensor_in = tf.placeholder(tf.int64, [10, 2])
         one_hot_tensor = ops.one_hot_matrix(tensor_in, 3)
         res = sess.run(ops.one_hot_matrix([[0, 1], [2, 1]], 3))
     self.assertAllEqual(one_hot_tensor.get_shape(), [10, 2, 3])
     self.assertAllEqual(
         res, [[[1.0, 0, 0], [0, 1.0, 0]], [[0, 0, 1.0], [0, 1.0, 0]]])