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

Method _Abs_helper

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

Source from the content-addressed store, hash-verified

585 self._MeanSquareError_helper(gpu_dev)
586
587 def _Abs_helper(self, dev):
588 X = np.array([0.8, -1.2, 3.3, -3.6, -0.5,
589 0.5]).reshape(3, 2).astype(np.float32)
590 XT = np.array([0.8, 1.2, 3.3, 3.6, 0.5,
591 0.5]).reshape(3, 2).astype(np.float32)
592 x = tensor.from_numpy(X)
593 x.to_device(dev)
594
595 result = autograd.abs(x)
596 dx = result.creator.backward(x.data)
597
598 np.testing.assert_array_almost_equal(tensor.to_numpy(result), XT)
599 self.check_shape(dx.shape(), (3, 2))
600
601 def test_Abs_cpu(self):
602 self._Abs_helper(cpu_dev)

Callers 2

test_Abs_cpuMethod · 0.95
test_Abs_gpuMethod · 0.95

Calls 5

check_shapeMethod · 0.95
shapeMethod · 0.80
reshapeMethod · 0.45
to_deviceMethod · 0.45
backwardMethod · 0.45

Tested by

no test coverage detected