diff pylearn/sampling/mcmc.py @ 1447:fbe470217937

Use .get_value() and .set_value() of shared instead of the .value property
author Pascal Lamblin <lamblinp@iro.umontreal.ca>
date Wed, 16 Mar 2011 20:20:02 -0400
parents 492473059b37
children
line wrap: on
line diff
--- a/pylearn/sampling/mcmc.py	Tue Mar 08 12:50:37 2011 -0500
+++ b/pylearn/sampling/mcmc.py	Wed Mar 16 20:20:02 2011 -0400
@@ -55,7 +55,7 @@
             The len of this vector is the batchsize.
         """
 
-        batchsize = positions[0].value.shape[0]
+        batchsize = positions[0].get_value(borrow=True).shape[0]
         self.s_rng = TT.shared_randomstreams.RandomStreams(seed)
         self.positions = positions
         self.prev_energy = shared(np.zeros(batchsize) + float('inf'))
@@ -64,7 +64,7 @@
 
         s_stepsize = TT.scalar('stepsize')
 
-        new_positions = [p + s_stepsize * self.s_rng.normal(size=p.value.shape)
+        new_positions = [p + s_stepsize * self.s_rng.normal(size=p.get_value(borrow=True).shape)
                 for p in self.positions]
 
         # accept-reject according to Metropolis-Hastings 
@@ -90,7 +90,7 @@
                 self.stepsize = min(self.stepsize*self.stepsize_inc,self.stepsize_max)
 
     def get_position(self):
-        return [q.value for q in self.positions]
+        return [q.get_value(borrow=True) for q in self.positions]
 
     def draw(self, n_steps=None):
         """Return the current sample in the Markov chain as a list of numpy arrays