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

Method _Asinh_helper

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

Source from the content-addressed store, hash-verified

971 self._Asin_helper(gpu_dev)
972
973 def _Asinh_helper(self, dev):
974 X = np.array([-0.9, -0.3, -0.1, 0.1, 0.5,
975 0.9]).reshape(3, 2).astype(np.float32)
976 XT = np.arcsinh(X)
977 DY = np.ones((3, 2), dtype=np.float32)
978
979 x = tensor.from_numpy(X)
980 dy = tensor.from_numpy(DY)
981 x.to_device(dev)
982 dy.to_device(dev)
983
984 result = autograd.asinh(x)
985 dx = result.creator.backward(dy.data)
986
987 G = 1.0 / np.sqrt(np.square(X) + 1.0)
988 DX = np.multiply(G, DY)
989
990 np.testing.assert_array_almost_equal(tensor.to_numpy(result),
991 XT,
992 decimal=5)
993 np.testing.assert_array_almost_equal(tensor.to_numpy(
994 tensor.from_raw_tensor(dx)),
995 DX,
996 decimal=5)
997
998 def test_Asinh_cpu(self):
999 self._Asinh_helper(cpu_dev)

Callers 2

test_Asinh_cpuMethod · 0.95
test_Asinh_gpuMethod · 0.95

Calls 3

reshapeMethod · 0.45
to_deviceMethod · 0.45
backwardMethod · 0.45

Tested by

no test coverage detected