Mercurial > ift6266
diff transformations/pipeline.py @ 115:b84a0d009af8
changes on pipeline mecanism: we now sample a different complexity for each transformations, this because when we use the same sampled complexity for all the modules 1/8 of the time we are close to 0 and we obtain an image very close to the source, we now save a complexity for each module in the parameters array
author | Xavier Glorot <glorotxa@iro.umontreal.ca> |
---|---|
date | Wed, 17 Feb 2010 16:20:15 -0500 |
parents | 9c45e0071b52 |
children | 3bec123dd75d |
line wrap: on
line diff
--- a/transformations/pipeline.py Wed Feb 17 09:29:19 2010 -0500 +++ b/transformations/pipeline.py Wed Feb 17 16:20:15 2010 -0500 @@ -102,7 +102,7 @@ self.res_data = numpy.empty((total, num_px), dtype=numpy.uint8) # +1 to store complexity - self.params = numpy.empty((total, self.num_params_stored+1)) + self.params = numpy.empty((total, self.num_params_stored+len(self.modules))) self.res_labels = numpy.empty(total, dtype=numpy.int32) def run(self, img_iterator, complexity_iterator): @@ -113,20 +113,28 @@ for img_no, (img, label) in enumerate(img_iterator): sys.stdout.flush() - complexity = complexity_iterator.next() - + global_idx = img_no img = img.reshape(img_size) - param_idx = 1 + param_idx = 0 + mod_idx = 0 # store complexity along with other params self.params[global_idx, 0] = complexity for mod in self.modules: # This used to be done _per batch_, - # ie. out of the "for img" loop + # ie. out of the "for img" loop + complexity = complexity_iterator.next() + #better to do a complexity sampling for each transformations in order to have more variability + #otherwise a lot of images similar to the source are generated (i.e. when complexity is close to 0 (1/8 of the time)) + #we need to save the complexity of each transformations and the sum of these complexity is a good indicator of the overall + #complexity + self.params[global_idx, mod_idx] = complexity + mod_idx += 1 + p = mod.regenerate_parameters(complexity) - self.params[global_idx, param_idx:param_idx+len(p)] = p + self.params[global_idx, param_idx+len(self.modules):param_idx+len(p)+len(self.modules)] = p param_idx += len(p) img = mod.transform_image(img)