singa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [incubator-singa] nudles commented on a change in pull request #478: SINGA-473 (Implement ONNX Operators in Autograd: Trigonometry functions)
Date Mon, 29 Jul 2019 01:48:45 GMT
nudles commented on a change in pull request #478: SINGA-473 (Implement ONNX Operators in Autograd:
Trigonometry functions)
URL: https://github.com/apache/incubator-singa/pull/478#discussion_r308032764
 
 

 ##########
 File path: test/python/test_operation.py
 ##########
 @@ -322,6 +322,294 @@ def test_LeakyRelu(self):
         np.testing.assert_array_almost_equal(tensor.to_numpy(result), XT)
         self.check_shape(dx.shape(), (3, 2))
 
+    def test_Cos_cpu(self):
+        X = np.array([0.8, -1.2, 3.3, -3.6, -0.5, 0.5]).reshape(3, 2).astype(np.float32)
+        XT = np.cos(X)
+        x = tensor.from_numpy(X)
+        x.to_device(cpu_dev)
+
+        result = autograd.cos(x)
+        dx = result.creator.backward(x.data)
+
+        np.testing.assert_array_almost_equal(tensor.to_numpy(result), XT, decimal=5)
+        self.check_shape(dx.shape(), (3, 2))
+
+    def test_Cos_gpu(self):
+        X = np.array([0.8, -1.2, 3.3, -3.6, -0.5, 0.5]).reshape(3, 2).astype(np.float32)
+        XT = np.cos(X)
+        x = tensor.from_numpy(X)
+        x.to_device(gpu_dev)
+
+        result = autograd.cos(x)
+        dx = result.creator.backward(x.data)
+
+        np.testing.assert_array_almost_equal(tensor.to_numpy(result), XT, decimal=5)
+        self.check_shape(dx.shape(), (3, 2))
+
+    def test_Cosh_cpu(self):
+        X = np.array([0.8, -1.2, 3.3, -3.6, -0.5, 0.5]).reshape(3, 2).astype(np.float32)
+        XT = np.cosh(X)
+        x = tensor.from_numpy(X)
+        x.to_device(cpu_dev)
+
+        result = autograd.cosh(x)
+        dx = result.creator.backward(x.data)
+
+        np.testing.assert_array_almost_equal(tensor.to_numpy(result), XT, decimal=5)
 
 Review comment:
   the backward results are not tested..

----------------------------------------------------------------
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