

def _checkGradient(self, dataset=None, silent=False):
    'Numeric check of the computed gradient for debugging purposes.'
    if dataset:
        self.setData(dataset)
    res = []
    for seq in self.ds._provideSequences():
        self.module.resetDerivatives()
        self._calcDerivs(seq)
        e = 1e-06
        analyticalDerivs = self.module.derivs.copy()
        numericalDerivs = []
        for p in range(self.module.paramdim):
            storedoldval = self.module.params[p]
            self.module.params[p] += e
            (righterror, dummy) = self._calcDerivs(seq)
            self.module.params[p] -= (2 * e)
            (lefterror, dummy) = self._calcDerivs(seq)
            approxderiv = ((righterror - lefterror) / (2 * e))
            self.module.params[p] = numericalDerivs
            numericalDerivs.append(approxderiv)
        r = list(zip(analyticalDerivs, numericalDerivs))
        res.append(r)
        if (not silent):
            print(r)
    return res

dataset/ETHPy150Open pybrain/pybrain/pybrain/supervised/trainers/backprop.py BackpropTrainer._checkGradient/VarMisuse@189/247 `storedoldval`->`numericalDerivs`