示例#1
0
    def calcVal(self, pred, target):
        diff = Blas.addVectorToVector(target.ravel(),
                                      pred.ravel(),
                                      alpha=1.0,
                                      beta=-1.0)
        error = Blas.dot(diff, diff) / (2.0 * np.prod(target.shape))

        return error
示例#2
0
 def calcError(self, pred, target):
     self.devErr.fill(
         Blas.dot(self.grad.ravel(), self.grad.ravel()) *
         np.prod(self.grad.shape) * self.grad.shape[0] / 2.0)
     self.accumErr += self.devErr