comparison dataset.py @ 253:394e07e2b0fd

code clean up
author Frederic Bastien <bastienf@iro.umontreal.ca>
date Tue, 03 Jun 2008 13:23:28 -0400
parents 856d14dc4468
children 8ec867d12428
comparison
equal deleted inserted replaced
252:856d14dc4468 253:394e07e2b0fd
1184 self.current+=1 1184 self.current+=1
1185 return self.example 1185 return self.example
1186 1186
1187 return CacheIteratorIter(self) 1187 return CacheIteratorIter(self)
1188 1188
1189 # class CachedDataSetIterator(object):
1190 # def __init__(self,dataset,fieldnames):#,minibatch_size,n_batches,offset):
1191 # # if fieldnames is None: fieldnames = dataset.fieldNames()
1192 # # store the resulting minibatch in a lookup-list of values
1193 # self.minibatch = LookupList(fieldnames,[0]*len(fieldnames))
1194 # self.dataset=dataset
1195 # # self.minibatch_size=minibatch_size
1196 # # assert offset>=0 and offset<len(dataset.data)
1197 # # assert offset+minibatch_size<=len(dataset.data)
1198 # self.current=0
1199 # self.columns = [self.dataset.fields_columns[f]
1200 # for f in self.minibatch._names]
1201 # self.l = len(self.dataset)
1202 # def __iter__(self):
1203 # return self
1204 # def next(self):
1205 # #@todo: we suppose that we need to stop only when minibatch_size == 1.
1206 # # Otherwise, MinibatchWrapAroundIterator do it.
1207 # if self.current>=self.l:
1208 # raise StopIteration
1209 # sub_data = self.dataset.data[self.current]
1210 # self.minibatch._values = [sub_data[c] for c in self.columns]
1211
1212 # self.current+=self.minibatch_size
1213 # return self.minibatch
1214
1215 # return CachedDataSetIterator(self,self.fieldNames())#,1,0,0)
1216
1217 class ApplyFunctionDataSet(DataSet): 1189 class ApplyFunctionDataSet(DataSet):
1218 """ 1190 """
1219 A L{DataSet} that contains as fields the results of applying a 1191 A L{DataSet} that contains as fields the results of applying a
1220 given function example-wise or minibatch-wise to all the fields of 1192 given function example-wise or minibatch-wise to all the fields of
1221 an input dataset. The output of the function should be an iterable 1193 an input dataset. The output of the function should be an iterable