(self, dev)
| 779 | self._Cos_helper(gpu_dev) |
| 780 | |
| 781 | def _Cosh_helper(self, dev): |
| 782 | X = np.array([0.8, -1.2, 3.3, -3.6, -0.5, |
| 783 | 0.5]).reshape(3, 2).astype(np.float32) |
| 784 | XT = np.cosh(X) |
| 785 | DY = np.ones((3, 2), dtype=np.float32) |
| 786 | |
| 787 | x = tensor.from_numpy(X) |
| 788 | dy = tensor.from_numpy(DY) |
| 789 | x.to_device(dev) |
| 790 | dy.to_device(dev) |
| 791 | |
| 792 | result = autograd.cosh(x) |
| 793 | dx = result.creator.backward(dy.data) |
| 794 | |
| 795 | G = np.sinh(X) |
| 796 | DX = np.multiply(G, DY) |
| 797 | |
| 798 | np.testing.assert_array_almost_equal(tensor.to_numpy(result), |
| 799 | XT, |
| 800 | decimal=5) |
| 801 | np.testing.assert_array_almost_equal(tensor.to_numpy( |
| 802 | tensor.from_raw_tensor(dx)), |
| 803 | DX, |
| 804 | decimal=5) |
| 805 | |
| 806 | def test_Cosh_cpu(self): |
| 807 | self._Cosh_helper(cpu_dev) |
no test coverage detected