コード例 #1
0
    def test_affine(self):
        with self.test_session() as sess:
            x = tf.placeholder(tf.float32, shape=[None, 3])
            z = graph.affine_layer(10, x)
            self.assertAllEqual(10, z.get_shape()[-1])

            x_val = np.array([[3., 2., 1.]])
            sess.run(tf.global_variables_initializer())
            z_val = sess.run(z, feed_dict={x: x_val})
            self.assertEquals((1, 10), z_val.shape)
            self.assertAllClose([[
                -0.92742872, 2.20097542, 0.72329885, -0.8619436, -0.09275365,
                1.63259518, 3.04762506, 0.80803722, 0.48845479, 2.23918748
            ]], z_val)
コード例 #2
0
    def test_affine(self):
        with self.test_session() as sess:
            x = tf.placeholder(tf.float32, shape=[None, 3])
            z = graph.affine_layer(10, x)
            # Verify graph properties.
            self.assertAllEqual(10, z.get_shape()[-1])

            # Setup for running the graph.
            sess.run(tf.global_variables_initializer())

            # Verify that dimensions work with more than one row.
            sess.run(z, feed_dict={x: np.array([[1., 2., 3.], [4., 5., 6.]])})

            # Verify computation correct.
            x_val = np.array([[3., 2., 1.]])
            z_val = sess.run(z, feed_dict={x: x_val})
            self.assertEquals((1, 10), z_val.shape)
            self.assertAllClose([[
                -0.92742872, 2.20097542, 0.72329885, -0.8619436, -0.09275365,
                1.63259518, 3.04762506, 0.80803722, 0.48845479, 2.23918748
            ]], z_val)
コード例 #3
0
    def test_affine(self):
        tf.set_random_seed(0)
        with self.test_session() as sess:
            x = tf.placeholder(tf.float32, shape=[None, 3])
            z = graph.affine_layer(10, x)
            # Verify graph properties.
            self.assertAllEqual(10, z.get_shape()[-1])

            # Setup for running the graph.
            sess.run(tf.global_variables_initializer())

            # Verify that dimensions work with more than one row.
            sess.run(z, feed_dict={x: np.array([[1., 2., 3.], [4., 5., 6.]])})

            # Verify computation correct.
            x_val = np.array([[3., 2., 1.]])
            z_val = sess.run(z, feed_dict={x: x_val})
            self.assertEqual((1, 10), z_val.shape)
            self.assertAllClose([[
                -1.477905, -0.144029, 0.96745, 0.491507, -0.105209, -0.558219,
                0.77895, 2.462549, -0.855641, 2.503024
            ]], z_val)
コード例 #4
0
    def test_affine(self):
        tf.set_random_seed(0)
        with self.test_session() as sess:
            x = tf.placeholder(tf.float32, shape=[None, 3])
            z = graph.affine_layer(10, x)
            # Verify graph properties.
            self.assertAllEqual(10, z.get_shape()[-1])

            # Setup for running the graph.
            sess.run(tf.global_variables_initializer())

            # Verify that dimensions work with more than one row.
            sess.run(z, feed_dict={
                x: np.array([[1., 2., 3.], [4., 5., 6.]])})

            # Verify computation correct.
            x_val = np.array([[3., 2., 1.]])
            z_val = sess.run(z, feed_dict={x: x_val})
            self.assertEqual((1, 10), z_val.shape)
            self.assertAllClose([[
              -1.477905, -0.144029,  0.96745,
              0.491507, -0.105209, -0.558219,
              0.77895 ,  2.462549, -0.855641,
              2.503024]], z_val)