changeset 805:c61d775f4f95

added a Tie initialisation of the weights option for DAA_inputs_groups
author Xavier Glorot <glorotxa@iro.umontreal.ca>
date Thu, 30 Jul 2009 18:09:17 -0400
parents 5e3b7dd6f96a
children a48ec81bec9d f4729745bb58
files pylearn/algorithms/sandbox/DAA_inputs_groups.py
diffstat 1 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/pylearn/algorithms/sandbox/DAA_inputs_groups.py	Tue Jul 28 11:50:07 2009 -0400
+++ b/pylearn/algorithms/sandbox/DAA_inputs_groups.py	Thu Jul 30 18:09:17 2009 -0400
@@ -397,7 +397,7 @@
         self.representation = theano.Method(listin, self.clean.hidden)
     
     def _instance_initialize(self, obj, lr = 1 , reg_coef = 0, noise_level = 0 , noise_level_group = 0, scale_cost_in = 1,
-                            scale_cost_aux = 1 , seed=1, orthoinit = False, alloc=True, **init):
+                            scale_cost_aux = 1 , seed=1, orthoinit = False, tieinit = False, alloc=True, **init):
         super(DAAig, self)._instance_initialize(obj, **init)
         
         obj.reg_coef = reg_coef
@@ -427,7 +427,8 @@
                 obj.bdec = numpy.zeros(self.in_size)
                 obj.wenc = self.R.uniform(size=wencshp, low = -self.inf, high = self.inf)
                 if not(self.tie_weights):
-                    obj.wdec = self.R.uniform(size=wdecshp, low=-self.hif, high=self.hif)
+                    obj.wdec = copy.copy(obj.wenc.T) if tieinit else \
+                            self.R.uniform(size=wdecshp,low=-self.hif,high=self.hif)
                 if orthoinit:
                     obj.wenc = orthogonalinit(obj.wenc)
                     if not(self.tie_weights):
@@ -441,7 +442,8 @@
                 obj.bauxdec = [numpy.zeros(i) for i in self.auxin_size]
                 obj.wauxenc = [self.R.uniform(size=i, low = -self.inf, high = self.inf) for i in wauxencshp]
                 if not(self.tie_weights):
-                    obj.wauxdec = [self.R.uniform(size=i, low=-self.hif, high=self.hif) for i in wauxdecshp]
+                    obj.wauxdec = [copy.copy(obj.wauxenc[i].T) for i in range(len(wauxdecshp))] if tieinit else\
+                            [self.R.uniform(size=i, low=-self.hif, high=self.hif) for i in wauxdecshp]
                 if orthoinit:
                     obj.wauxenc = [orthogonalinit(w) for w in obj.wauxenc]
                     if not(self.tie_weights):
@@ -702,7 +704,8 @@
                         theano.Method(self.inputs[-1],self.totalgradients[-1][0]+self.totalgradients[-1][1])
     
     def _instance_initialize(self,inst,unsup_lr = 0.01, sup_lr = 0.01, reg_coef = 0, scale_cost_in = 1, scale_cost_aux = 1,
-                                noise_level = 0 , noise_level_group = 0, seed = 1, orthoinit = False, alloc = True,**init):
+                                noise_level = 0 , noise_level_group = 0, seed = 1, orthoinit = False, tieinit=False,
+                                alloc = True,**init):
         super(StackedDAAig, self)._instance_initialize(inst, **init)
         
         inst.unsup_lr = unsup_lr
@@ -715,7 +718,7 @@
                     scale_cost_in = scale_cost_in[i] if type(scale_cost_in) is list else scale_cost_in, \
                     scale_cost_aux = scale_cost_aux[i] if type(scale_cost_aux) is list else scale_cost_aux, \
                     noise_level_group = noise_level_group[i] if type(noise_level_group) is list else noise_level_group, \
-                    seed = seed + i, orthoinit = orthoinit, alloc = alloc)
+                    seed = seed + i, orthoinit = orthoinit, tieinit = tieinit, alloc = alloc)
         
         print '\tLayer supervised'
         inst.daaig[-1].initialize()