changeset 1275:f0129e37a8ef

mcRBM - changed params from lambda to method for pickling
author James Bergstra <bergstrj@iro.umontreal.ca>
date Wed, 08 Sep 2010 13:18:13 -0400
parents 9d5905d6d879
children 822c7691a759
files pylearn/algorithms/mcRBM.py
diffstat 1 files changed, 13 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/pylearn/algorithms/mcRBM.py	Wed Sep 08 13:17:45 2010 -0400
+++ b/pylearn/algorithms/mcRBM.py	Wed Sep 08 13:18:13 2010 -0400
@@ -413,6 +413,15 @@
                 params = [self.U, self.W, self.b, self.c],
                 )
 
+    def params(self):
+        """Return the elements of [U,W,a,b,c] that are shared variables
+
+        WRITEME : a *prescriptive* definition of this method suitable for mention in the API
+        doc.
+        
+        """
+        return list(self._params)
+
     @classmethod
     def alloc(cls, n_I, n_K, n_J, rng = 8923402190,
             U_range=0.02,
@@ -440,8 +449,7 @@
                 a = sharedX(np.ones(n_I)*a_ival,'a'),
                 b = sharedX(np.ones(n_K)*b_ival,'b'),
                 c = sharedX(np.ones(n_J)*c_ival,'c'),)
-
-        rval.params = lambda : [rval.U, rval.W, rval.a, rval.b, rval.c]
+        rval._params = [rval.U, rval.W, rval.a, rval.b, rval.c]
         return rval
 
 class mcRBMTrainer(object):
@@ -565,6 +573,9 @@
             as_unittest=False,
             n_train_iters=10)
     import cPickle
+    print ''
+    print 'Saving rbm...'
     cPickle.dump(rbm, open('mcRBM.rbm.pkl', 'w'), -1)
+    print 'Saving sampler...'
     cPickle.dump(smplr, open('mcRBM.smplr.pkl', 'w'), -1)