changeset 1322:cdda4f98c2a2

mcRBM - added mask for updates to P matrix
author James Bergstra <bergstrj@iro.umontreal.ca>
date Sun, 10 Oct 2010 13:45:21 -0400
parents ebcb76b38817
children d6726417cf57
files pylearn/algorithms/mcRBM.py
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/pylearn/algorithms/mcRBM.py	Sun Oct 10 13:43:53 2010 -0400
+++ b/pylearn/algorithms/mcRBM.py	Sun Oct 10 13:45:21 2010 -0400
@@ -654,6 +654,8 @@
         rval = cls.alloc(rbm, visible_batch, batchsize, initial_lr_per_example, rng, l1_penalty,
                 l1_penalty_start, learn_rate_multipliers, lr_anneal_start, persistent_chains)
 
+        rval.p_mask = sharedX((rbm.P.value!=0).astype('float32'), 'p_mask')
+
         rval.p_lr = p_lr
         rval.p_training_start=p_training_start
         rval.p_training_lr=p_training_lr
@@ -795,7 +797,9 @@
             ups[self.p_lr] = TT.switch(self.iter > self.p_training_start,
                     self.p_training_lr,
                     0)
-            ups[self.rbm.P] = TT.clip(ups[self.rbm.P], -5, 0)
+            new_P = ups[self.rbm.P] * self.p_mask
+            no_pos_P = TT.switch(new_P<0, new_P, 0)
+            ups[self.rbm.P] = - no_pos_P / no_pos_P.sum(axis=0) #normalize to that columns sum 1
 
         return ups