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

Method _Acos_helper

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

Source from the content-addressed store, hash-verified

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)

Callers 2

test_Acos_cpuMethod · 0.95
test_Acos_gpuMethod · 0.95

Calls 3

reshapeMethod · 0.45
to_deviceMethod · 0.45
backwardMethod · 0.45

Tested by

no test coverage detected