def setField(self, label, arr, **kwargs): """Set the given array `arr` as the new array of the field specfied by `label`.""" DataSet.setField(self, label, arr, **kwargs) # refresh dimensions, in case any of these fields were modified if label == 'input': self.indim = self.getDimension('input') elif label == 'target': self.outdim = self.getDimension('target')
def __reduce__(self): # FIXME: This does actually not feel right: We have to use the DataSet # method here, although we inherit from sequential dataset. _, _, state, _, _ = DataSet.__reduce__(self) creator = self.__class__ args = self.statedim, self.actiondim return creator, args, state, iter([]), iter({})
def __init__(self, inp, target): """Initialize an empty supervised dataset. Pass `inp` and `target` to specify the dimensions of the input and target vectors.""" DataSet.__init__(self) if isscalar(inp): # add input and target fields and link them self.addField('input', inp) self.addField('target', target) else: self.setField('input', inp) self.setField('target', target) self.linkFields(['input', 'target']) # reset the index marker self.index = 0 # the input and target dimensions self.indim = self.getDimension('input') self.outdim = self.getDimension('target')
def __init__(self, statedim, actiondim): """ initialize the reinforcement dataset, add the 3 fields state, action and reward, and create an index marker. This class is basically a wrapper function that renames the fields of SupervisedDataSet into the more common reinforcement learning names. Instead of 'episodes' though, we deal with 'sequences' here. """ DataSet.__init__(self) # add 3 fields: input, target, importance self.addField('state', statedim) self.addField('action', actiondim) self.addField('reward', 1) # link these 3 fields self.linkFields(['state', 'action', 'reward']) # reset the index marker self.index = 0 # add field that stores the beginning of a new episode self.addField('sequence_index', 1) self.append('sequence_index', 0) self.currentSeq = 0 self.statedim = statedim self.actiondim = actiondim # the input and target dimensions (for compatibility) self.indim = self.statedim self.outdim = self.actiondim
def __init__(self, dim): DataSet.__init__(self) self.addField('loglh', dim) self.linkFields(['loglh']) self.index = 0
def __init__(self, dim): DataSet.__init__(self) self.addField("loglh", dim) self.linkFields(["loglh"]) self.index = 0