Mercurial > pylearn
comparison pylearn/sampling/hmc.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 | 746ebceeb46f |
children | 55534951dd91 |
comparison
equal
deleted
inserted
replaced
1446:6e50d209b5f1 | 1447:fbe470217937 |
---|---|
235 respect to the positions for HMC sampling to work. | 235 respect to the positions for HMC sampling to work. |
236 """ | 236 """ |
237 # allocate shared vars | 237 # allocate shared vars |
238 | 238 |
239 if shared_positions_shape==None: | 239 if shared_positions_shape==None: |
240 shared_positions_shape = shared_positions.value.shape | 240 shared_positions_shape = shared_positions.get_value(borrow=True).shape |
241 batchsize = shared_positions_shape[0] | 241 batchsize = shared_positions_shape[0] |
242 | 242 |
243 stepsize = shared(numpy.asarray(initial_stepsize).astype(theano.config.floatX), 'hmc_stepsize') | 243 stepsize = shared(numpy.asarray(initial_stepsize).astype(theano.config.floatX), 'hmc_stepsize') |
244 avg_acceptance_rate = shared(target_acceptance_rate, 'avg_acceptance_rate') | 244 avg_acceptance_rate = shared(target_acceptance_rate, 'avg_acceptance_rate') |
245 s_rng = TT.shared_randomstreams.RandomStreams(seed) | 245 s_rng = TT.shared_randomstreams.RandomStreams(seed) |
287 The `kwargs` dictionary is passed to the shared variable (self.positions) `get_value()` | 287 The `kwargs` dictionary is passed to the shared variable (self.positions) `get_value()` |
288 function. So for example, to avoid copying the shared variable value, consider passing | 288 function. So for example, to avoid copying the shared variable value, consider passing |
289 `borrow=True`. | 289 `borrow=True`. |
290 """ | 290 """ |
291 self.simulate() | 291 self.simulate() |
292 return self.positions.value.copy() | 292 return self.positions.get_value(borrow=False) |
293 | 293 |
294 def updates(self): | 294 def updates(self): |
295 """Returns the update expressions required to simulate the Markov Chain | 295 """Returns the update expressions required to simulate the Markov Chain |
296 | 296 |
297 :TODO: :WRITEME: *prescriptive* definition of what this method does (API) | 297 :TODO: :WRITEME: *prescriptive* definition of what this method does (API) |