# HG changeset patch # User Xavier Glorot # Date 1248991757 14400 # Node ID c61d775f4f9543417aadebbdc2761719b424bf61 # Parent 5e3b7dd6f96a9a7dc138eb0c80c4735ef1f23030 added a Tie initialisation of the weights option for DAA_inputs_groups diff -r 5e3b7dd6f96a -r c61d775f4f95 pylearn/algorithms/sandbox/DAA_inputs_groups.py --- 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()