Mercurial > pylearn
comparison dataset.py @ 310:ebccfd05ccd5
dataset.subset implemented
author | Thierry Bertin-Mahieux <bertinmt@iro.umontreal.ca> |
---|---|
date | Wed, 11 Jun 2008 11:43:54 -0400 |
parents | 923de30457f0 |
children | 009ce84e9f52 |
comparison
equal
deleted
inserted
replaced
309:923de30457f0 | 310:ebccfd05ccd5 |
---|---|
504 return example | 504 return example |
505 | 505 |
506 # what in the world is i? | 506 # what in the world is i? |
507 raise TypeError(i, type(i)) | 507 raise TypeError(i, type(i)) |
508 | 508 |
509 | |
510 """ | |
511 Enables the call dataset.subset[a:b:c] that will return a DataSet | |
512 around the examples returned by __getitem__(slice(a,b,c)) | |
513 | |
514 @SEE DataSet.__getsubset(self) | |
515 """ | |
516 subset = property(lambda s : s.__getsubset(),doc="returns a subset as a DataSet") | |
517 | |
518 | |
519 def __getsubset(self) : | |
520 """ | |
521 Enables the call data.subset[a:b:c], returns a DataSet. | |
522 Default implementation is a simple wrap around __getitem__() using MinibatchDataSet. | |
523 | |
524 @RETURN DataSet | |
525 @SEE DataSet.subset = property(lambda s : s.__getsubset()) | |
526 """ | |
527 _self = self | |
528 class GetSliceReturnsDataSet(object) : | |
529 def __getitem__(self,slice) : | |
530 return MinibatchDataSet(_self.__getitem__(slice)) | |
531 return GetSliceReturnsDataSet() | |
532 | |
533 | |
534 | |
509 def valuesHStack(self,fieldnames,fieldvalues): | 535 def valuesHStack(self,fieldnames,fieldvalues): |
510 """ | 536 """ |
511 Return a value that corresponds to concatenating (horizontally) several field values. | 537 Return a value that corresponds to concatenating (horizontally) several field values. |
512 This can be useful to merge some fields. The implementation of this operation is likely | 538 This can be useful to merge some fields. The implementation of this operation is likely |
513 to involve a copy of the original values. When the values are numpy arrays, the | 539 to involve a copy of the original values. When the values are numpy arrays, the |