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

Method _Cosh_helper

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

Source from the content-addressed store, hash-verified

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)

Callers 2

test_Cosh_cpuMethod · 0.95
test_Cosh_gpuMethod · 0.95

Calls 3

reshapeMethod · 0.45
to_deviceMethod · 0.45
backwardMethod · 0.45

Tested by

no test coverage detected