Exemplo n.º 1
0
 def testNoInts(self):
     with self.cached_session():
         with self.assertRaisesRegexp(
                 TypeError,
                 "'features' has DataType int32 not in list of allowed values"
         ):
             nn_ops.softsign(constant_op.constant(7)).eval()
Exemplo n.º 2
0
 def _testSoftsign(self, np_features, use_gpu=False):
   np_softsign = self._npSoftsign(np_features)
   with self.cached_session(use_gpu=use_gpu):
     softsign = nn_ops.softsign(np_features)
     tf_softsign = self.evaluate(softsign)
   self.assertAllClose(np_softsign, tf_softsign)
   self.assertShapeEqual(np_softsign, softsign)
Exemplo n.º 3
0
 def _testSoftsign(self, np_features, use_gpu=False):
     np_softsign = self._npSoftsign(np_features)
     with self.cached_session(use_gpu=use_gpu):
         softsign = nn_ops.softsign(np_features)
         tf_softsign = self.evaluate(softsign)
     self.assertAllClose(np_softsign, tf_softsign)
     self.assertShapeEqual(np_softsign, softsign)
Exemplo n.º 4
0
 def testGradient(self):
     with self.test_session():
         x = constant_op.constant([-0.9, -0.7, -0.5, -0.3, -0.1, 0.1, 0.3, 0.5, 0.7, 0.9], shape=[2, 5], name="x")
         y = nn_ops.softsign(x, name="softsign")
         x_init = np.asarray(
             [[-0.9, -0.7, -0.5, -0.3, -0.1], [0.1, 0.3, 0.5, 0.7, 0.9]], dtype=np.float32, order="F"
         )
         err = gradient_checker.compute_gradient_error(x, [2, 5], y, [2, 5], x_init_value=x_init)
     print("softsign (float) gradient err = ", err)
     self.assertLess(err, 1e-4)
Exemplo n.º 5
0
 def testGradient(self):
   with self.cached_session():
     x = constant_op.constant(
         [-0.9, -0.7, -0.5, -0.3, -0.1, 0.1, 0.3, 0.5, 0.7, 0.9],
         shape=[2, 5],
         name="x")
     y = nn_ops.softsign(x, name="softsign")
     x_init = np.asarray(
         [[-0.9, -0.7, -0.5, -0.3, -0.1], [0.1, 0.3, 0.5, 0.7, 0.9]],
         dtype=np.float32,
         order="F")
     err = gradient_checker.compute_gradient_error(
         x, [2, 5], y, [2, 5], x_init_value=x_init)
   print("softsign (float) gradient err = ", err)
   self.assertLess(err, 1e-4)
Exemplo n.º 6
0
 def testNoInts(self):
   with self.cached_session():
     with self.assertRaisesRegexp(
         TypeError,
         "'features' has DataType int32 not in list of allowed values"):
       nn_ops.softsign(constant_op.constant(7)).eval()
 def testNoInts(self):
   with self.cached_session():
     with self.assertRaisesRegexp(
         errors.InvalidArgumentError,
         "No OpKernel was registered to support Op 'Softsign'"):
       nn_ops.softsign(constant_op.constant(7)).eval()
Exemplo n.º 8
0
 def testWarnInts(self):
     # NOTE(irving): Actually I don't know how to intercept the warning, but
     # let's make sure it runs.  I promised I've looked, and there was a warning.
     with self.test_session():
         nn_ops.softsign(constant_op.constant(7)).eval()
Exemplo n.º 9
0
 def testNoInts(self):
   with self.test_session():
     with self.assertRaisesRegexp(
         errors.InvalidArgumentError,
         "No OpKernel was registered to support Op 'Softsign'"):
       nn_ops.softsign(constant_op.constant(7)).eval()
Exemplo n.º 10
0
 def testWarnInts(self):
   # NOTE(irving): Actually I don't know how to intercept the warning, but
   # let's make sure it runs.  I promised I've looked, and there was a warning.
   with self.test_session():
     nn_ops.softsign(constant_op.constant(7)).eval()