Mercurial > pylearn
comparison dataset.py @ 85:7b1f3ad3d60b
bugfix
author | Frederic Bastien <bastienf@iro.umontreal.ca> |
---|---|
date | Mon, 05 May 2008 13:37:39 -0400 |
parents | c0f211213a58 |
children | 6749d18e11c8 |
comparison
equal
deleted
inserted
replaced
84:aa9e786ee849 | 85:7b1f3ad3d60b |
---|---|
608 return (self.examples() | other.examples()).fields() | 608 return (self.examples() | other.examples()).fields() |
609 | 609 |
610 | 610 |
611 class MinibatchDataSet(DataSet): | 611 class MinibatchDataSet(DataSet): |
612 """ | 612 """ |
613 Turn a LookupList of same-length fields into an example-iterable dataset. | 613 Turn a LookupList of same-length (iterable) fields into an example-iterable dataset. |
614 Each element of the lookup-list should be an iterable and sliceable, all of the same length. | 614 Each element of the lookup-list should be an iterable and sliceable, all of the same length. |
615 """ | 615 """ |
616 def __init__(self,fields_lookuplist,values_vstack=DataSet().valuesVStack, | 616 def __init__(self,fields_lookuplist,values_vstack=DataSet().valuesVStack, |
617 values_hstack=DataSet().valuesHStack): | 617 values_hstack=DataSet().valuesHStack): |
618 """ | 618 """ |
634 def __getitem__(self,i): | 634 def __getitem__(self,i): |
635 if type(i) in (slice,list): | 635 if type(i) in (slice,list): |
636 return DataSetFields(MinibatchDataSet( | 636 return DataSetFields(MinibatchDataSet( |
637 Example(self._fields.keys(),[field[i] for field in self._fields])),self.fieldNames()) | 637 Example(self._fields.keys(),[field[i] for field in self._fields])),self.fieldNames()) |
638 if type(i) is int: | 638 if type(i) is int: |
639 return DataSetFields(MinibatchDataSet( | 639 return Example(self._fields.keys(),[field[i] for field in self._fields]) |
640 Example(self._fields.keys(),[[field[i]] for field in self._fields])),self.fieldNames()) | |
641 | |
642 if self.hasFields(i): | 640 if self.hasFields(i): |
643 return self._fields[i] | 641 return self._fields[i] |
644 assert i in self.__dict__ # else it means we are trying to access a non-existing property | 642 assert i in self.__dict__ # else it means we are trying to access a non-existing property |
645 return self.__dict__[i] | 643 return self.__dict__[i] |
646 | 644 |