MCPcopy Create free account
hub / github.com/apache/singa / _Sinh_helper

Method _Sinh_helper

test/python/test_operation.py:909–932  ·  view source on GitHub ↗
(self, dev)

Source from the content-addressed store, hash-verified

907 self._Sin_helper(gpu_dev)
908
909 def _Sinh_helper(self, dev):
910 X = np.array([0.8, -1.2, 3.3, -3.6, -0.5,
911 0.5]).reshape(3, 2).astype(np.float32)
912 XT = np.sinh(X)
913 DY = np.ones((3, 2), dtype=np.float32)
914
915 x = tensor.from_numpy(X)
916 dy = tensor.from_numpy(DY)
917 x.to_device(dev)
918 dy.to_device(dev)
919
920 result = autograd.sinh(x)
921 dx = result.creator.backward(dy.data)
922
923 G = np.cosh(X)
924 DX = np.multiply(G, DY)
925
926 np.testing.assert_array_almost_equal(tensor.to_numpy(result),
927 XT,
928 decimal=5)
929 np.testing.assert_array_almost_equal(tensor.to_numpy(
930 tensor.from_raw_tensor(dx)),
931 DX,
932 decimal=5)
933
934 def test_Sinh_cpu(self):
935 self._Sinh_helper(cpu_dev)

Callers 2

test_Sinh_cpuMethod · 0.95
test_Sinh_gpuMethod · 0.95

Calls 3

reshapeMethod · 0.45
to_deviceMethod · 0.45
backwardMethod · 0.45

Tested by

no test coverage detected