comparison dataset.py @ 331:52aa031e1fe3

IMPORTANT: minibatches now returns minibatch_nowrap with a minimum of assert before. Should implement the good behavior, e.g. returning only complete batches and let the user figure out what he wants.
author Thierry Bertin-Mahieux <bertinmt@iro.umontreal.ca>
date Mon, 16 Jun 2008 16:38:03 -0400
parents 20e08c52c98c
children dada08a6adb8
comparison
equal deleted inserted replaced
330:20e08c52c98c 331:52aa031e1fe3
366 366
367 - minibatch_size (integer, default 1) 367 - minibatch_size (integer, default 1)
368 On every iteration, the variables i1, i2, i3 will have 368 On every iteration, the variables i1, i2, i3 will have
369 exactly minibatch_size elements. e.g. len(i1) == minibatch_size 369 exactly minibatch_size elements. e.g. len(i1) == minibatch_size
370 370
371 @DEPRECATED n_batches : not used anywhere
371 - n_batches (integer, default None) 372 - n_batches (integer, default None)
372 The iterator will loop exactly this many times, and then stop. If None, 373 The iterator will loop exactly this many times, and then stop. If None,
373 the derived class can choose a default. If (-1), then the returned 374 the derived class can choose a default. If (-1), then the returned
374 iterator should support looping indefinitely. 375 iterator should support looping indefinitely.
375 376
377 The iterator will start at example 'offset' in the dataset, rather than the default. 378 The iterator will start at example 'offset' in the dataset, rather than the default.
378 379
379 Note: A list-like container is something like a tuple, list, numpy.ndarray or 380 Note: A list-like container is something like a tuple, list, numpy.ndarray or
380 any other object that supports integer indexing and slicing. 381 any other object that supports integer indexing and slicing.
381 382
382 """ 383 @ATTENTION: now minibatches returns minibatches_nowrap, which is supposed to return complete
383 return DataSet.MinibatchWrapAroundIterator(self,fieldnames,minibatch_size,n_batches,offset) 384 batches only, raise StopIteration
385
386 """
387 #return DataSet.MinibatchWrapAroundIterator(self,fieldnames,minibatch_size,n_batches,offset)\
388 assert offset >= 0
389 assert offset < len(self)
390 assert offset + minibatch_size < len(self)
391 return minibatch_nowrap(fieldnames,minibatch_size,n_batches,offset)
384 392
385 def minibatches_nowrap(self,fieldnames,minibatch_size,n_batches,offset): 393 def minibatches_nowrap(self,fieldnames,minibatch_size,n_batches,offset):
386 """ 394 """
387 This is the minibatches iterator generator that sub-classes must define. 395 This is the minibatches iterator generator that sub-classes must define.
388 It does not need to worry about wrapping around multiple times across the dataset, 396 It does not need to worry about wrapping around multiple times across the dataset,