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

Method _Asin_helper

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

Source from the content-addressed store, hash-verified

939 self._Sinh_helper(gpu_dev)
940
941 def _Asin_helper(self, dev):
942 X = np.array([-0.9, -0.3, -0.1, 0.1, 0.5,
943 0.9]).reshape(3, 2).astype(np.float32)
944 XT = np.arcsin(X)
945 DY = np.ones((3, 2), dtype=np.float32)
946
947 x = tensor.from_numpy(X)
948 dy = tensor.from_numpy(DY)
949 x.to_device(dev)
950 dy.to_device(dev)
951
952 result = autograd.asin(x)
953 dx = result.creator.backward(dy.data)
954
955 G = 1.0 / np.sqrt(1.0 - np.square(X))
956 DX = np.multiply(G, DY)
957
958 np.testing.assert_array_almost_equal(tensor.to_numpy(result),
959 XT,
960 decimal=5)
961 np.testing.assert_array_almost_equal(tensor.to_numpy(
962 tensor.from_raw_tensor(dx)),
963 DX,
964 decimal=5)
965
966 def test_Asin_cpu(self):
967 self._Asin_helper(cpu_dev)

Callers 2

test_Asin_cpuMethod · 0.95
test_Asin_gpuMethod · 0.95

Calls 3

reshapeMethod · 0.45
to_deviceMethod · 0.45
backwardMethod · 0.45

Tested by

no test coverage detected