Esempio n. 1
0
 def testNumbersWithAxis1(self):
     tf_crelu = nn_ops.crelu(np.array([[-9, 7, -5, 3, -1],
                                       [1, -3, 5, -7, 9]]),
                             axis=1)
     np_crelu = np.array([[0, 7, 0, 3, 0, 9, 0, 5, 0, 1],
                          [1, 0, 5, 0, 9, 0, 3, 0, 7, 0]])
     self.assertAllEqual(np_crelu, tf_crelu)
Esempio n. 2
0
 def test(self):
   np.random.seed(1)  # Make it reproducible.
   x = np.random.randn(3, 4).astype(np.float32)
   y = np.concatenate([x * (x > 0), -x * (x < 0)], axis=1)
   with self.test_session():
     z = nn_ops.crelu(constant_op.constant(x)).eval()
     self.assertAllClose(y, z, 1e-4)
Esempio n. 3
0
 def test(self):
     np.random.seed(1)  # Make it reproducible.
     x = np.random.randn(3, 4).astype(np.float32)
     y = np.concatenate([x * (x > 0), -x * (x < 0)], axis=1)
     with self.test_session():
         z = nn_ops.crelu(constant_op.constant(x)).eval()
         self.assertAllClose(y, z, 1e-4)
Esempio n. 4
0
 def testNumbersWithAxis1(self):
   with self.cached_session():
     crelu = nn_ops.crelu(
         np.array([[-9, 7, -5, 3, -1], [1, -3, 5, -7, 9]]), axis=1)
     tf_relu = crelu.eval()
     np_crelu = np.array([[0, 7, 0, 3, 0, 9, 0, 5, 0, 1],
                          [1, 0, 5, 0, 9, 0, 3, 0, 7, 0]])
     self.assertAllEqual(np_crelu, tf_relu)
Esempio n. 5
0
 def testNumbersWithAxis1(self):
   with self.test_session():
     crelu = nn_ops.crelu(
         np.array([[-9, 7, -5, 3, -1], [1, -3, 5, -7, 9]]), axis=1)
     tf_relu = crelu.eval()
     np_crelu = np.array([[0, 7, 0, 3, 0, 9, 0, 5, 0, 1],
                          [1, 0, 5, 0, 9, 0, 3, 0, 7, 0]])
     self.assertAllEqual(np_crelu, tf_relu)
Esempio n. 6
0
    def _testCrelu(self, np_features):
        np_relu = np.maximum(np_features, np.zeros_like(np_features))
        np_neg_relu = np.maximum(-np_features, np.zeros_like(np_features))
        np_crelu = np.concatenate((np_relu, np_neg_relu),
                                  len(np_features.shape) - 1)

        tf_crelu = nn_ops.crelu(np_features)

        self.assertAllClose(np_crelu, tf_crelu)
        self.assertShapeEqual(np_crelu, tf_crelu)
Esempio n. 7
0
  def _testCrelu(self, np_features):
    np_relu = np.maximum(np_features, np.zeros_like(np_features))
    np_neg_relu = np.maximum(-np_features, np.zeros_like(np_features))
    np_crelu = np.concatenate((np_relu, np_neg_relu),
                              len(np_features.shape) - 1)

    tf_crelu = nn_ops.crelu(np_features)

    self.assertAllClose(np_crelu, tf_crelu)
    self.assertShapeEqual(np_crelu, tf_crelu)
Esempio n. 8
0
    def _testCrelu(self, np_features, use_gpu=False):
        np_relu = np.maximum(np_features, np.zeros_like(np_features))
        np_neg_relu = np.maximum(-np_features, np.zeros_like(np_features))
        np_crelu = np.concatenate((np_relu, np_neg_relu),
                                  len(np_features.shape) - 1)

        with self.test_session(use_gpu=use_gpu):
            crelu = nn_ops.crelu(np_features)
            tf_relu = crelu.eval()

        self.assertAllClose(np_crelu, tf_relu)
        self.assertShapeEqual(np_crelu, crelu)
Esempio n. 9
0
  def _testCrelu(self, np_features, use_gpu=False):
    np_relu = np.maximum(np_features, np.zeros_like(np_features))
    np_neg_relu = np.maximum(-np_features, np.zeros_like(np_features))
    np_crelu = np.concatenate((np_relu, np_neg_relu),
                              len(np_features.shape) - 1)

    with self.test_session(use_gpu=use_gpu):
      crelu = nn_ops.crelu(np_features)
      tf_relu = crelu.eval()

    self.assertAllClose(np_crelu, tf_relu)
    self.assertShapeEqual(np_crelu, crelu)
Esempio n. 10
0
 def testCreluShape(self):
     f = random_ops.random_normal([50, 5, 7, 10])
     t = nn_ops.crelu(f)
     self.assertEqual([50, 5, 7, 20], t.get_shape())
Esempio n. 11
0
 def testCreluShape(self):
   f = random_ops.random_normal([50, 5, 7, 10])
   t = nn_ops.crelu(f)
   self.assertEqual([50, 5, 7, 20], t.get_shape())
Esempio n. 12
0
 def testNumbersWithAxis1(self):
   tf_crelu = nn_ops.crelu(
       np.array([[-9, 7, -5, 3, -1], [1, -3, 5, -7, 9]]), axis=1)
   np_crelu = np.array([[0, 7, 0, 3, 0, 9, 0, 5, 0, 1],
                        [1, 0, 5, 0, 9, 0, 3, 0, 7, 0]])
   self.assertAllEqual(np_crelu, tf_crelu)