nudles commented on a change in pull request #482: SINGA-474 hardsigmoid operator URL: https://github.com/apache/incubator-singa/pull/482#discussion_r308032587
########## 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: backward is 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: us...@infra.apache.org With regards, Apache Git Services