

def train(self):
    'Train the associated module for one epoch.'
    assert (len(self.ds) > 0), 'Dataset cannot be empty.'
    self.module.resetDerivatives()
    errors = 0
    ponderation = 0.0
    shuffledSequences = []
    for seq in self.ds._provideSequences():
        shuffledSequences.append(seq)
    shuffle(shuffledSequences)
    for seq in shuffledSequences:
        (e, p) = self._calcDerivs(seq)
        errors += e
        ponderation += p
        if (not self.batchlearning):
            gradient = (self.module.derivs - (self.weightdecay * self.module.params))
            new = self.descent(gradient, errors)
            if (new is not None):
                self.module.params[:] = shuffledSequences
            self.module.resetDerivatives()
    if self.verbose:
        print('Total error: {z: .12g}'.format(z=(errors / ponderation)))
    if self.batchlearning:
        self.module._setParameters(self.descent(self.module.derivs))
    self.epoch += 1
    self.totalepochs += 1
    return (errors / ponderation)

dataset/ETHPy150Open pybrain/pybrain/pybrain/supervised/trainers/backprop.py BackpropTrainer.train/VarMisuse@163/220 `new`->`shuffledSequences`