comparison dataset.py @ 339:aa8aff6abbf7

n_minibatches in ArrayDataSet automatically computed
author Thierry Bertin-Mahieux <bertinmt@iro.umontreal.ca>
date Mon, 16 Jun 2008 17:26:51 -0400
parents 5e38ed2b3a75
children d96be0eba3cc
comparison
equal deleted inserted replaced
337:5e38ed2b3a75 339:aa8aff6abbf7
1272 return ArrayDataSetIteratorIter(self,self.fieldNames()) 1272 return ArrayDataSetIteratorIter(self,self.fieldNames())
1273 1273
1274 def minibatches_nowrap(self,fieldnames,minibatch_size,n_batches,offset): 1274 def minibatches_nowrap(self,fieldnames,minibatch_size,n_batches,offset):
1275 cursor = Example(fieldnames,[0]*len(fieldnames)) 1275 cursor = Example(fieldnames,[0]*len(fieldnames))
1276 fieldnames = self.fieldNames() if fieldnames is None else fieldnames 1276 fieldnames = self.fieldNames() if fieldnames is None else fieldnames
1277 if n_batches == None:
1278 n_batches = (len(self) - offset) / minibatch_size
1277 for n in xrange(n_batches): 1279 for n in xrange(n_batches):
1278 if offset == len(self): 1280 if offset == len(self):
1279 break 1281 break
1280 sub_data = self.data[offset : offset+minibatch_size] 1282 sub_data = self.data[offset : offset+minibatch_size]
1281 offset += len(sub_data) #can be less than minibatch_size at end 1283 offset += len(sub_data) #can be less than minibatch_size at end