[GitHub] [incubator-singa] joddiy commented on a change in pull request #483: SINGA-474 identity operator

2019-08-05 Thread GitBox
joddiy commented on a change in pull request #483: SINGA-474 identity operator
URL: https://github.com/apache/incubator-singa/pull/483#discussion_r310513923
 
 

 ##
 File path: test/python/test_operation.py
 ##
 @@ -322,6 +336,37 @@ def test_LeakyRelu(self):
 np.testing.assert_array_almost_equal(tensor.to_numpy(result), XT)
 self.check_shape(dx.shape(), (3, 2))
 
+def test_Identity_cpu(self):
+x = np.array([-0.9, -0.3, -0.1, 0.1, 0.5, 0.9]).reshape(3, 
2).astype(np.float32)
+y = x.copy()
+lossf=lambda x:np.sum(x)
 
 Review comment:
   Got it.  It's ok.


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


[GitHub] [incubator-singa] joddiy commented on a change in pull request #483: SINGA-474 identity operator

2019-08-05 Thread GitBox
joddiy commented on a change in pull request #483: SINGA-474 identity operator
URL: https://github.com/apache/incubator-singa/pull/483#discussion_r310474400
 
 

 ##
 File path: test/python/test_operation.py
 ##
 @@ -322,6 +336,37 @@ def test_LeakyRelu(self):
 np.testing.assert_array_almost_equal(tensor.to_numpy(result), XT)
 self.check_shape(dx.shape(), (3, 2))
 
+def test_Identity_cpu(self):
+x = np.array([-0.9, -0.3, -0.1, 0.1, 0.5, 0.9]).reshape(3, 
2).astype(np.float32)
+y = x.copy()
+lossf=lambda x:np.sum(x)
 
 Review comment:
   why the lossf is ```np.sum```? I think for the identity, the lossf is just 
```x```.


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


[GitHub] [incubator-singa] joddiy commented on a change in pull request #483: SINGA-474 identity operator

2019-08-01 Thread GitBox
joddiy commented on a change in pull request #483: SINGA-474 identity operator
URL: https://github.com/apache/incubator-singa/pull/483#discussion_r309664758
 
 

 ##
 File path: test/python/test_operation.py
 ##
 @@ -322,6 +322,27 @@ def test_LeakyRelu(self):
 np.testing.assert_array_almost_equal(tensor.to_numpy(result), XT)
 self.check_shape(dx.shape(), (3, 2))
 
+def test_Identity_cpu(self):
+x = np.array([-0.9, -0.3, -0.1, 0.1, 0.5, 0.9]).reshape(3, 
2).astype(np.float32)
+y = x.copy()
+x = tensor.from_numpy(x)
+x.to_device(cpu_dev)
 
+result = autograd.identity(x)
+dx = result.creator.backward(x.data)
+
+np.testing.assert_array_almost_equal(tensor.to_numpy(result), y, 
decimal=5)
+self.check_shape(dx.shape(), (3, 2))
+def test_Identity_gpu(self):
+x = np.array([-0.9, -0.3, -0.1, 0.1, 0.5, 0.9]).reshape(3, 
2).astype(np.float32)
+y = x.copy()
+x = tensor.from_numpy(x)
+x.to_device(gpu_dev)
+
+result = autograd.identity(x)
+dx = result.creator.backward(x.data)
+
+np.testing.assert_array_almost_equal(tensor.to_numpy(result), y, 
decimal=5)
 
 Review comment:
   please add the test case of backward propagation.


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


[GitHub] [incubator-singa] joddiy commented on a change in pull request #483: SINGA-474 identity operator

2019-08-01 Thread GitBox
joddiy commented on a change in pull request #483: SINGA-474 identity operator
URL: https://github.com/apache/incubator-singa/pull/483#discussion_r309664724
 
 

 ##
 File path: test/python/test_operation.py
 ##
 @@ -322,6 +322,27 @@ def test_LeakyRelu(self):
 np.testing.assert_array_almost_equal(tensor.to_numpy(result), XT)
 self.check_shape(dx.shape(), (3, 2))
 
+def test_Identity_cpu(self):
+x = np.array([-0.9, -0.3, -0.1, 0.1, 0.5, 0.9]).reshape(3, 
2).astype(np.float32)
+y = x.copy()
+x = tensor.from_numpy(x)
+x.to_device(cpu_dev)
 
+result = autograd.identity(x)
+dx = result.creator.backward(x.data)
+
+np.testing.assert_array_almost_equal(tensor.to_numpy(result), y, 
decimal=5)
 
 Review comment:
   please add the test case of backward propagation.


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