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

Method _MeanSquareError_helper

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

Source from the content-addressed store, hash-verified

561 self._numerical_gradients_check_for_lstm_helper(gpu_dev)
562
563 def _MeanSquareError_helper(self, dev):
564 X = np.array([4.3, 5.4, 3.3, 3.6, 5.7,
565 6.0]).reshape(3, 2).astype(np.float32)
566 T = np.array([4.4, 5.3, 3.2, 3.7, 5.4,
567 6.3]).reshape(3, 2).astype(np.float32)
568 x = tensor.from_numpy(X)
569 t = tensor.from_numpy(T)
570 x.to_device(dev)
571 t.to_device(dev)
572
573 loss = autograd.mse_loss(x, t)
574 dx = loss.creator.backward()
575
576 loss_np = tensor.to_numpy(loss)[0]
577 self.assertAlmostEqual(loss_np, 0.0366666, places=4)
578 self.check_shape(dx.shape(), (3, 2))
579
580 def test_MeanSquareError_cpu(self):
581 self._MeanSquareError_helper(cpu_dev)

Callers 2

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