<s> from __future__ import print_function <EOL> __author__ = '<STR_LIT>' <EOL> from scipy import sqrt <EOL> from pybrain . supervised . trainers import BackpropTrainer <EOL> class RPropMinusTrainer ( BackpropTrainer ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , module , etaminus = <NUM_LIT:0.5> , etaplus = <NUM_LIT> , deltamin = <NUM_LIT> , deltamax = <NUM_LIT> , delta0 = <NUM_LIT:0.1> , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> BackpropTrainer . __init__ ( self , module , ** kwargs ) <EOL> self . epoch = <NUM_LIT:0> <EOL> self . descent . rprop = True <EOL> self . descent . etaplus = etaplus <EOL> self . descent . etaminus = etaminus <EOL> self . descent . deltamin = deltamin <EOL> self . descent . deltamax = deltamax <EOL> self . descent . deltanull = delta0 <EOL> self . descent . init ( module . params ) <EOL> def train ( self ) : <EOL> """<STR_LIT>""" <EOL> self . module . resetDerivatives ( ) <EOL> errors = <NUM_LIT:0> <EOL> ponderation = <NUM_LIT:0> <EOL> for seq in self . ds . _provideSequences ( ) : <EOL> e , p = self . _calcDerivs ( seq ) <EOL> errors += e <EOL> ponderation += p <EOL> if self . verbose : <EOL> print ( ( "<STR_LIT>" . format ( <EOL> epoch = self . epoch , <EOL> error = errors / ponderation , <EOL> weight = sqrt ( ( self . module . params ** <NUM_LIT:2> ) . mean ( ) ) ) ) ) <EOL> self . module . _setParameters ( self . descent ( self . module . derivs - self . weightdecay * self . module . params ) ) <EOL> self . epoch += <NUM_LIT:1> <EOL> self . totalepochs += <NUM_LIT:1> <EOL> return errors / ponderation </s>
