joddiy commented on a change in pull request #496: SINGA-474 Mean operator
URL: https://github.com/apache/incubator-singa/pull/496#discussion_r310467053
 
 

 ##########
 File path: test/python/test_operation.py
 ##########
 @@ -322,6 +335,48 @@ def test_LeakyRelu(self):
         np.testing.assert_array_almost_equal(tensor.to_numpy(result), XT)
         self.check_shape(dx.shape(), (3, 2))
 
+    def test_Mean_gpu(self):
+        x0 = np.array([-0.9, -0.3, -0.1, 0.1, 0.5, 0.9]).reshape(3, 
2).astype(np.float32)
+        x1 = np.array([0, -0.3, 0, 0.1, 0, 0.9]).reshape(3, 
2).astype(np.float32)
+        y = (x0+x1)/2
+        lossf =lambda x,y:np.sum((x+y)/2)
+        grad=eval_numerical_gradient(lossf,x0,x1)
+        grad1=eval_numerical_gradient(lossf,x1,x0)
 
 Review comment:
   For example, the function is ```(X + X')/2```, at the first call, you 
calculate the gradient of x0 based on (x0+x1)/2, but at the second call, you 
calculate the gradient at x1 based on (x1+x0)/2. I think the two are still same.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to