(self, x)
| 1338 | self.t = t.data |
| 1339 | |
| 1340 | def forward(self, x): |
| 1341 | self.err = singa.__sub__(x, self.t) |
| 1342 | sqr = singa.Square(self.err) |
| 1343 | loss = singa.SumAll(sqr) |
| 1344 | self.n = 1 |
| 1345 | for s in x.shape(): |
| 1346 | self.n *= s |
| 1347 | loss /= self.n |
| 1348 | return loss |
| 1349 | |
| 1350 | def backward(self, dy=1.0): |
| 1351 | dx = self.err |