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

Method _Atan_helper

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

Source from the content-addressed store, hash-verified

1067 self._Tanh_helper(gpu_dev)
1068
1069 def _Atan_helper(self, dev):
1070 X = np.array([-0.9, -0.3, -0.1, 0.1, 0.5,
1071 0.9]).reshape(3, 2).astype(np.float32)
1072 XT = np.arctan(X)
1073 DY = np.ones((3, 2), dtype=np.float32)
1074
1075 x = tensor.from_numpy(X)
1076 dy = tensor.from_numpy(DY)
1077 x.to_device(dev)
1078 dy.to_device(dev)
1079
1080 result = autograd.atan(x)
1081 dx = result.creator.backward(dy.data)
1082
1083 G = 1.0 / (1.0 + np.square(X))
1084 DX = np.multiply(G, DY)
1085
1086 np.testing.assert_array_almost_equal(tensor.to_numpy(result),
1087 XT,
1088 decimal=5)
1089 np.testing.assert_array_almost_equal(tensor.to_numpy(
1090 tensor.from_raw_tensor(dx)),
1091 DX,
1092 decimal=5)
1093
1094 def test_Atan_cpu(self):
1095 self._Atan_helper(cpu_dev)

Callers 2

test_Atan_cpuMethod · 0.95
test_Atan_gpuMethod · 0.95

Calls 3

reshapeMethod · 0.45
to_deviceMethod · 0.45
backwardMethod · 0.45

Tested by

no test coverage detected