Mercurial > ift6266
diff transformations/pipeline.py @ 66:bf83682c827b
merge
author | Xavier Glorot <glorotxa@iro.umontreal.ca> |
---|---|
date | Tue, 09 Feb 2010 18:45:35 -0500 |
parents | 1afa95285b9c |
children | 5e448ea129b3 |
line wrap: on
line diff
--- a/transformations/pipeline.py Tue Feb 09 18:31:24 2010 -0500 +++ b/transformations/pipeline.py Tue Feb 09 18:45:35 2010 -0500 @@ -192,12 +192,16 @@ self.train_data = open(nist_path, 'rb') self.train_labels = open(label_path, 'rb') self.dim = tuple(ft._read_header(self.train_data)[3]) + # in order to seek to the beginning of the file + self.train_data.close() + self.train_data = open(nist_path, 'rb') + def nist_supp_iterator(nist, prob_font, prob_captcha, num_img): subtensor = slice(0, num_img) img = ft.read(nist.train_data, subtensor).astype(numpy.float32)/255 labels = ft.read(nist.train_labels, subtensor) - + for i in xrange(num_img): r = numpy.random.rand() if r<= prob_font: