Mercurial > ift6266
changeset 25:a679c1ffb5c5
Merged
author | fsavard <francois.savard@polymtl.ca> |
---|---|
date | Fri, 29 Jan 2010 13:38:37 -0500 |
parents | 010e826b41e8 (current diff) 442789c94b27 (diff) |
children | e5ee2c9a9517 |
files | |
diffstat | 2 files changed, 42 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/deepmlp.py Fri Jan 29 13:37:52 2010 -0500 +++ b/scripts/deepmlp.py Fri Jan 29 13:38:37 2010 -0500 @@ -102,8 +102,8 @@ # L1 norm ; one regularization option is to enforce L1 norm to # be small - self.L1=abs(self.W[i]).sum() - self.L2_sqr=abs(self.W[i]).sum() + self.L1=abs(self.W[0]).sum() + self.L2_sqr=abs(self.W[0]).sum() for i in range(1,n_layer+1): self.L1 += abs(self.W[i]).sum() # square of L2 norm ; one regularization option is to enforce
--- a/transformations/thick.py Fri Jan 29 13:37:52 2010 -0500 +++ b/transformations/thick.py Fri Jan 29 13:38:37 2010 -0500 @@ -21,8 +21,8 @@ #---------- private attributes self.__nx__ = 32 #xdim of the images self.__ny__ = 32 #ydim of the images - self.__erodemax__ = 4 #nb of index max of erode structuring elements - self.__dilatemax__ = 11 #nb of index max of dilation structuring elements + self.__erodemax__ = 9 #nb of index max of erode structuring elements + self.__dilatemax__ = 9 #nb of index max of dilation structuring elements self.__structuring_elements__ = [N.asarray([[1,1]]),N.asarray([[1],[1]]),\ N.asarray([[1,1],[1,1]]),N.asarray([[0,1,0],[1,1,1],[0,1,0]]),\ N.asarray([[1,1,1],[1,1,1]]),N.asarray([[1,1],[1,1],[1,1]]),\ @@ -47,7 +47,7 @@ self.erodenb = N.ceil(complexity * self.__erodemax__) self.dilatenb = N.ceil(complexity * self.__dilatemax__) self.Perode = self.erodenb / (self.dilatenb + self.erodenb + 1.0) - self.Pdilate = self.dilatenb / (self.dilatenb + self.erodenb + 1.0) + self.Pdilate = self.dilatenb / (self.dilatenb + self.erodenb + 1.0) assert (self.Perode + self.Pdilate <= 1) & (self.Perode + self.Pdilate >= 0) assert (complexity >= 0) & (complexity <= 1) P = N.random.uniform() @@ -124,20 +124,20 @@ pygame.surfarray.use_arraytype('numpy') pygame.display.init() - screen = pygame.display.set_mode((8*2*32,8*32),0,8) + screen = pygame.display.set_mode((8*4*32,8*32),0,8) anglcolorpalette=[(x,x,x) for x in xrange(0,256)] screen.set_palette(anglcolorpalette) MyThick = Thick() - debut=time.time() - MyThick.transform_image(d) - fin=time.time() - print '------------------------------------------------' - print d.shape[0],' images transformed in :', fin-debut, ' seconds' - print '------------------------------------------------' - print (fin-debut)/d.shape[0]*1000000,' microseconds per image' - print '------------------------------------------------' + #debut=time.time() + #MyThick.transform_image(d) + #fin=time.time() + #print '------------------------------------------------' + #print d.shape[0],' images transformed in :', fin-debut, ' seconds' + #print '------------------------------------------------' + #print (fin-debut)/d.shape[0]*1000000,' microseconds per image' + #print '------------------------------------------------' #print MyThick.get_settings_names() #print MyThick._get_current_parameters() #print MyThick.regenerate_parameters(0) @@ -154,7 +154,9 @@ new.set_palette(anglcolorpalette) screen.blit(new,(0,0)) - print MyThick.get_settings_names(), MyThick.regenerate_parameters(1) + #max dilation + MyThick.meth=1 + MyThick.nb=MyThick.__dilatemax__ c=MyThick.transform_image(a) b=N.asarray(N.reshape(c,(32,32))).T @@ -165,6 +167,31 @@ new.set_palette(anglcolorpalette) screen.blit(new,(8*32,0)) + #max erosion + MyThick.meth=-1 + MyThick.nb=MyThick.__erodemax__ + c=MyThick.transform_image(a) + b=N.asarray(N.reshape(c,(32,32))).T + + new=pygame.surfarray.make_surface(b) + new=pygame.transform.scale2x(new) + new=pygame.transform.scale2x(new) + new=pygame.transform.scale2x(new) + new.set_palette(anglcolorpalette) + screen.blit(new,(8*2*32,0)) + + #random + print MyThick.get_settings_names(), MyThick.regenerate_parameters(1) + c=MyThick.transform_image(a) + b=N.asarray(N.reshape(c,(32,32))).T + + new=pygame.surfarray.make_surface(b) + new=pygame.transform.scale2x(new) + new=pygame.transform.scale2x(new) + new=pygame.transform.scale2x(new) + new.set_palette(anglcolorpalette) + screen.blit(new,(8*3*32,0)) + pygame.display.update() raw_input('Press Enter')