nudles commented on a change in pull request #435: SINGA-425 Add 3 operators
URL: https://github.com/apache/incubator-singa/pull/435#discussion_r255300670
 
 

 ##########
 File path: test/python/test_operation.py
 ##########
 @@ -264,6 +264,48 @@ def test_MeanSquareError(self):
         loss_np=tensor.to_numpy(loss)
         self.assertAlmostEqual(loss_np, 0.0366666, places=4)
         self.check_shape(dx.shape(), (3, 2))
+        
+    def test_Abs(self):
+        
X=np.array([0.8,-1.2,3.3,-3.6,-0.5,0.5]).reshape(3,2).astype(np.float32)
+        XT=np.array([0.8,1.2,3.3,3.6,0.5,0.5]).reshape(3,2).astype(np.float32)
+        x=tensor.from_numpy(X)
+        x.to_device(gpu_dev)
+
+        result=autograd.abs(x)
+        Err=XT-rerult
+        dx=result.creator.backward()[0]
+
+        for ii in Err.flatten():
+            self.assertAlmostEquals(ii,0., places=3)
+        self.check_shape(dx.shape(), (3, 2))
+        
+    def test_Exp(self):
+        
X=np.array([0.8,-1.2,3.3,-3.6,-0.5,0.5]).reshape(3,2).astype(np.float32)
+        
XT=np.array([2.2255409,0.22313017,27.112638,0.02732372,0.60653067,1.6487212]).reshape(3,2).astype(np.float32)
+        x=tensor.from_numpy(X)
+        x.to_device(gpu_dev)
+
+        result=autograd.exp(x)
+        Err=XT-rerult
 
 Review comment:
   rerult --> result?
   have you managed to run it?

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


With regards,
Apache Git Services

Reply via email to