singa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [incubator-singa] ShichengChen commented on a change in pull request #482: SINGA-474 hardsigmoid operator
Date Mon, 29 Jul 2019 12:11:11 GMT
ShichengChen commented on a change in pull request #482: SINGA-474 hardsigmoid operator
URL: https://github.com/apache/incubator-singa/pull/482#discussion_r308194700
 
 

 ##########
 File path: test/python/test_operation.py
 ##########
 @@ -321,7 +321,34 @@ def test_LeakyRelu(self):
 
         np.testing.assert_array_almost_equal(tensor.to_numpy(result), XT)
         self.check_shape(dx.shape(), (3, 2))
+    def test_HardSigmoid_cpu(self):
+        x = np.array([-0.9, -0.3, -0.1, 0.1, 0.5, 0.9]).reshape(3, 2).astype(np.float32)
+        #y = max(0, min(1, alpha * x + gamma))
+        a=0.5
+        g=0.6
+        y = np.clip(x * 0.5 + 0.6, 0, 1)
+        x = tensor.from_numpy(x)
+        x.to_device(cpu_dev)
+
+        result = autograd.hardsigmoid(x,a,g)
+        dx = result.creator.backward(x.data)
+
+        np.testing.assert_array_almost_equal(tensor.to_numpy(result), y, decimal=5)
 
 Review comment:
   yes, I just added test

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message