(self, dev)
| 811 | self._Cosh_helper(gpu_dev) |
| 812 | |
| 813 | def _Acos_helper(self, dev): |
| 814 | X = np.array([-0.9, -0.3, -0.1, 0.1, 0.5, |
| 815 | 0.9]).reshape(3, 2).astype(np.float32) |
| 816 | XT = np.arccos(X) |
| 817 | DY = np.ones((3, 2), dtype=np.float32) |
| 818 | |
| 819 | x = tensor.from_numpy(X) |
| 820 | dy = tensor.from_numpy(DY) |
| 821 | x.to_device(dev) |
| 822 | dy.to_device(dev) |
| 823 | |
| 824 | result = autograd.acos(x) |
| 825 | dx = result.creator.backward(dy.data) |
| 826 | |
| 827 | G = -1.0 / np.sqrt(1.0 - np.square(X)) |
| 828 | DX = np.multiply(G, DY) |
| 829 | |
| 830 | np.testing.assert_array_almost_equal(tensor.to_numpy(result), |
| 831 | XT, |
| 832 | decimal=5) |
| 833 | np.testing.assert_array_almost_equal(tensor.to_numpy( |
| 834 | tensor.from_raw_tensor(dx)), |
| 835 | DX, |
| 836 | decimal=5) |
| 837 | |
| 838 | def test_Acos_cpu(self): |
| 839 | self._Acos_helper(cpu_dev) |
no test coverage detected