comparison datasets/gzpklfile.py @ 262:716c99f4eb3a

merge
author Xavier Glorot <glorotxa@iro.umontreal.ca>
date Wed, 17 Mar 2010 16:41:51 -0400
parents c2fae7b96769
children
comparison
equal deleted inserted replaced
261:6d16a2bf142b 262:716c99f4eb3a
17 res = self.ary[self.pos:self.pos+num] 17 res = self.ary[self.pos:self.pos+num]
18 self.pos += num 18 self.pos += num
19 return res 19 return res
20 20
21 class GzpklDataSet(DataSet): 21 class GzpklDataSet(DataSet):
22 def __init__(self, fname): 22 def __init__(self, fname, maxsize):
23 self._fname = fname 23 self._fname = fname
24 self.maxsize = maxsize
24 self._train = 0 25 self._train = 0
25 self._valid = 1 26 self._valid = 1
26 self._test = 2 27 self._test = 2
27 28
28 def _load(self): 29 def _load(self):
33 f.close() 34 f.close()
34 35
35 def _return_it(self, batchsz, bufsz, id): 36 def _return_it(self, batchsz, bufsz, id):
36 if not hasattr(self, 'datas'): 37 if not hasattr(self, 'datas'):
37 self._load() 38 self._load()
38 return izip(DataIterator([ArrayFile(self.datas[id][0])], batchsz, bufsz), 39 return izip(DataIterator([ArrayFile(self.datas[id][0][:self.maxsize])], batchsz, bufsz),
39 DataIterator([ArrayFile(self.datas[id][1])], batchsz, bufsz)) 40 DataIterator([ArrayFile(self.datas[id][1][:self.maxsize])], batchsz, bufsz))