<s> __author__ = '<STR_LIT>' <EOL> from pybrain . datasets . sequential import SequentialDataSet <EOL> from pybrain . datasets . dataset import DataSet <EOL> from scipy import zeros <EOL> class ReinforcementDataSet ( SequentialDataSet ) : <EOL> def __init__ ( self , statedim , actiondim ) : <EOL> """<STR_LIT>""" <EOL> DataSet . __init__ ( self ) <EOL> self . addField ( '<STR_LIT:state>' , statedim ) <EOL> self . addField ( '<STR_LIT:action>' , actiondim ) <EOL> self . addField ( '<STR_LIT>' , <NUM_LIT:1> ) <EOL> self . linkFields ( [ '<STR_LIT:state>' , '<STR_LIT:action>' , '<STR_LIT>' ] ) <EOL> self . index = <NUM_LIT:0> <EOL> self . addField ( '<STR_LIT>' , <NUM_LIT:1> ) <EOL> self . append ( '<STR_LIT>' , <NUM_LIT:0> ) <EOL> self . currentSeq = <NUM_LIT:0> <EOL> self . statedim = statedim <EOL> self . actiondim = actiondim <EOL> self . indim = self . statedim <EOL> self . outdim = self . actiondim <EOL> def addSample ( self , state , action , reward ) : <EOL> """<STR_LIT>""" <EOL> self . appendLinked ( state , action , reward ) <EOL> def getSumOverSequences ( self , field ) : <EOL> sums = zeros ( ( self . getNumSequences ( ) , self . getDimension ( field ) ) ) <EOL> for n in range ( self . getNumSequences ( ) ) : <EOL> sums [ n , : ] = sum ( self . _getSequenceField ( n , field ) , <NUM_LIT:0> ) <EOL> return sums <EOL> def __reduce__ ( self ) : <EOL> _ , _ , state , _ , _ = DataSet . __reduce__ ( self ) <EOL> creator = self . __class__ <EOL> args = self . statedim , self . actiondim <EOL> return creator , args , state , iter ( [ ] ) , iter ( { } ) </s>
