# HG changeset patch # User Frederic Bastien # Date 1212513881 14400 # Node ID 8ec867d124280b3aa82b95e5385f360676e8ecc3 # Parent 394e07e2b0fdc62993818a51111a5f865c3b4974 optimication in CachedDataSet.minibatches_nowrap diff -r 394e07e2b0fd -r 8ec867d12428 dataset.py --- a/dataset.py Tue Jun 03 13:23:28 2008 -0400 +++ b/dataset.py Tue Jun 03 13:24:41 2008 -0400 @@ -1141,6 +1141,7 @@ def __init__(self,dataset): self.dataset=dataset self.current=offset + self.all_fields = self.dataset.fieldNames()==fieldnames def __iter__(self): return self def next(self): upper = self.current+minibatch_size @@ -1152,7 +1153,7 @@ all_fields_minibatch = Example(self.dataset.fieldNames(), zip(*self.dataset.cached_examples[self.current:self.current+minibatch_size])) self.current+=minibatch_size - if self.dataset.fieldNames()==fieldnames: + if self.all_fields: return all_fields_minibatch return Example(fieldnames,[all_fields_minibatch[name] for name in fieldnames]) return CacheIterator(self)