Mercurial > ift6266
comparison transformations/pipeline.py @ 64:1afa95285b9c
fixed small bug related to loading the data - should seek back to the beginning of the file
author | Dumitru Erhan <dumitru.erhan@gmail.com> |
---|---|
date | Tue, 09 Feb 2010 18:25:50 -0500 |
parents | cc4be6b25b8e |
children | 5e448ea129b3 |
comparison
equal
deleted
inserted
replaced
63:7949f46b03e0 | 64:1afa95285b9c |
---|---|
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: |