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

Method _Sin_helper

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

Source from the content-addressed store, hash-verified

875 self._Acosh_helper(gpu_dev)
876
877 def _Sin_helper(self, dev):
878 X = np.array([0.8, -1.2, 3.3, -3.6, -0.5,
879 0.5]).reshape(3, 2).astype(np.float32)
880 XT = np.sin(X)
881 DY = np.ones((3, 2), dtype=np.float32)
882
883 x = tensor.from_numpy(X)
884 dy = tensor.from_numpy(DY)
885 x.to_device(dev)
886 dy.to_device(dev)
887
888 result = autograd.sin(x)
889 dx = result.creator.backward(dy.data)
890
891 G = np.cos(X)
892 DX = np.multiply(G, DY)
893
894 np.testing.assert_array_almost_equal(tensor.to_numpy(result),
895 XT,
896 decimal=5)
897 np.testing.assert_array_almost_equal(tensor.to_numpy(
898 tensor.from_raw_tensor(dx)),
899 DX,
900 decimal=5)
901
902 def test_Sin_cpu(self):
903 self._Sin_helper(cpu_dev)

Callers 2

test_Sin_cpuMethod · 0.95
test_Sin_gpuMethod · 0.95

Calls 3

reshapeMethod · 0.45
to_deviceMethod · 0.45
backwardMethod · 0.45

Tested by

no test coverage detected