(self, dev)
| 1099 | self._Atan_helper(gpu_dev) |
| 1100 | |
| 1101 | def _Atanh_helper(self, dev): |
| 1102 | X = np.array([-0.9, -0.3, -0.1, 0.1, 0.5, |
| 1103 | 0.9]).reshape(3, 2).astype(np.float32) |
| 1104 | XT = np.arctanh(X) |
| 1105 | DY = np.ones((3, 2), dtype=np.float32) |
| 1106 | |
| 1107 | x = tensor.from_numpy(X) |
| 1108 | dy = tensor.from_numpy(DY) |
| 1109 | x.to_device(dev) |
| 1110 | dy.to_device(dev) |
| 1111 | |
| 1112 | result = autograd.atanh(x) |
| 1113 | dx = result.creator.backward(dy.data) |
| 1114 | |
| 1115 | G = 1.0 / (1.0 - np.square(X)) |
| 1116 | DX = np.multiply(G, DY) |
| 1117 | |
| 1118 | np.testing.assert_array_almost_equal(tensor.to_numpy(result), |
| 1119 | XT, |
| 1120 | decimal=5) |
| 1121 | np.testing.assert_array_almost_equal(tensor.to_numpy( |
| 1122 | tensor.from_raw_tensor(dx)), |
| 1123 | DX, |
| 1124 | decimal=5) |
| 1125 | |
| 1126 | def test_Atanh_cpu(self): |
| 1127 | self._Atanh_helper(cpu_dev) |
no test coverage detected