comparison dataset.py @ 153:71107b0ac860

optimization
author Frederic Bastien <bastienf@iro.umontreal.ca>
date Mon, 12 May 2008 16:12:29 -0400
parents 39bb21348fdf
children f8a1ae7eb83e
comparison
equal deleted inserted replaced
151:39bb21348fdf 153:71107b0ac860
1081 if self.dataset.fieldNames()==fieldnames: 1081 if self.dataset.fieldNames()==fieldnames:
1082 return all_fields_minibatch 1082 return all_fields_minibatch
1083 return Example(fieldnames,[all_fields_minibatch[name] for name in fieldnames]) 1083 return Example(fieldnames,[all_fields_minibatch[name] for name in fieldnames])
1084 return CacheIterator(self) 1084 return CacheIterator(self)
1085 1085
1086 def __getitem__(self,i):
1087 if type(i)==int and len(self.cached_examples)>i:
1088 return self.cached_examples[i]
1089 else:
1090 return DataSet.__getitem__(self,i)
1086 1091
1087 class ApplyFunctionDataSet(DataSet): 1092 class ApplyFunctionDataSet(DataSet):
1088 """ 1093 """
1089 A dataset that contains as fields the results of applying a given function 1094 A dataset that contains as fields the results of applying a given function
1090 example-wise or minibatch-wise to all the fields of an input dataset. 1095 example-wise or minibatch-wise to all the fields of an input dataset.