def test_grad(self): with self.test_session(): shape = (5,) x = tf.constant([5, 4, 3, 2, 1], dtype=tf.float32) y = zero_out_op_2.zero_out(x) err = tf.test.compute_gradient_error(x, shape, y, shape) self.assertLess(err, 1e-4)
def test_grad_2d(self): with self.cached_session(): shape = (2, 3) x = tf.constant([[6, 5, 4], [3, 2, 1]], dtype=tf.float32) y = zero_out_op_2.zero_out(x) err = tf.test.compute_gradient_error(x, shape, y, shape) self.assertLess(err, 1e-4)
def test_grad(self): with self.cached_session(): shape = (5, ) x = tf.constant([5, 4, 3, 2, 1], dtype=tf.float32) y = zero_out_op_2.zero_out(x) err = tf.test.compute_gradient_error(x, shape, y, shape) self.assertLess(err, 1e-4)
def test_2d(self): with self.cached_session(): result = zero_out_op_2.zero_out([[6, 5, 4], [3, 2, 1]]) self.assertAllEqual(result.eval(), [[6, 0, 0], [0, 0, 0]])
def test(self): with self.cached_session(): result = zero_out_op_2.zero_out([5, 4, 3, 2, 1]) self.assertAllEqual(result.eval(), [5, 0, 0, 0, 0])
def test_2d(self): result = zero_out_op_2.zero_out([[6, 5, 4], [3, 2, 1]]) self.assertAllEqual(result, [[6, 0, 0], [0, 0, 0]])
def test(self): result = zero_out_op_2.zero_out([5, 4, 3, 2, 1]) self.assertAllEqual(result, [5, 0, 0, 0, 0])