comparison datasets/ftfile.py @ 178:938bd350dbf0

Make the datasets iterators return theano shared slices with the appropriate types.
author Arnaud Bergeron <abergeron@gmail.com>
date Sat, 27 Feb 2010 15:09:02 -0500
parents be714ac9bcbd
children 76bc047df5ee
comparison
equal deleted inserted replaced
177:be714ac9bcbd 178:938bd350dbf0
1 from pylearn.io.filetensor import _read_header, _prod 1 from pylearn.io.filetensor import _read_header, _prod
2 import numpy 2 import numpy, theano
3 from dataset import DataSet 3 from dataset import DataSet
4 from dsetiter import DataIterator 4 from dsetiter import DataIterator
5 from itertools import izip 5 from itertools import izip, imap
6 6
7 class FTFile(object): 7 class FTFile(object):
8 def __init__(self, fname): 8 def __init__(self, fname):
9 r""" 9 r"""
10 Tests: 10 Tests:
180 self._valid = FTData(valid_data, valid_lbl) 180 self._valid = FTData(valid_data, valid_lbl)
181 self._test = FTData(test_data, test_lbl) 181 self._test = FTData(test_data, test_lbl)
182 182
183 def _return_it(self, batchsize, bufsize, ftdata): 183 def _return_it(self, batchsize, bufsize, ftdata):
184 return izip(DataIterator(ftdata.open_inputs(), batchsize, bufsize), 184 return izip(DataIterator(ftdata.open_inputs(), batchsize, bufsize),
185 DataIterator(ftdata.open_outputs(), batchsize, bufsize)) 185 imap(lambda b: theano.tensor.cast(b, 'int32'),
186 DataIterator(ftdata.open_outputs(), batchsize, bufsize)))