(self, dev)
| 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) |
no test coverage detected