Mercurial > ift6266
comparison 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 |
comparison
equal
deleted
inserted
replaced
65:ab70fbca513c | 66:bf83682c827b |
---|---|
190 class NistData(): | 190 class NistData(): |
191 def __init__(self, nist_path, label_path): | 191 def __init__(self, nist_path, label_path): |
192 self.train_data = open(nist_path, 'rb') | 192 self.train_data = open(nist_path, 'rb') |
193 self.train_labels = open(label_path, 'rb') | 193 self.train_labels = open(label_path, 'rb') |
194 self.dim = tuple(ft._read_header(self.train_data)[3]) | 194 self.dim = tuple(ft._read_header(self.train_data)[3]) |
195 # in order to seek to the beginning of the file | |
196 self.train_data.close() | |
197 self.train_data = open(nist_path, 'rb') | |
198 | |
195 | 199 |
196 def nist_supp_iterator(nist, prob_font, prob_captcha, num_img): | 200 def nist_supp_iterator(nist, prob_font, prob_captcha, num_img): |
197 subtensor = slice(0, num_img) | 201 subtensor = slice(0, num_img) |
198 img = ft.read(nist.train_data, subtensor).astype(numpy.float32)/255 | 202 img = ft.read(nist.train_data, subtensor).astype(numpy.float32)/255 |
199 labels = ft.read(nist.train_labels, subtensor) | 203 labels = ft.read(nist.train_labels, subtensor) |
200 | 204 |
201 for i in xrange(num_img): | 205 for i in xrange(num_img): |
202 r = numpy.random.rand() | 206 r = numpy.random.rand() |
203 if r<= prob_font: | 207 if r<= prob_font: |
204 pass #get font | 208 pass #get font |
205 elif r<= prob_font + prob_captcha: | 209 elif r<= prob_font + prob_captcha: |