66"""
77
88
9- import numpy , time , cPickle , gzip , PIL .Image
9+ import numpy , time , cPickle , gzip , sys , os , PIL .Image
1010
1111import theano
1212import theano .tensor as T
@@ -281,7 +281,8 @@ def test_rbm(learning_rate=0.1, training_epochs = 15,
281281 # Training the RBM #
282282 #################################
283283 dirname = 'lr=%.5f' % learning_rate
284- os .makedirs (dirname )
284+ if not os .path .exists (dirname ):
285+ os .makedirs (dirname )
285286 os .chdir (dirname )
286287
287288 # it is ok for a theano function to have no output
@@ -317,7 +318,7 @@ def test_rbm(learning_rate=0.1, training_epochs = 15,
317318 end_time = time .clock ()
318319
319320 pretraining_time = (end_time - start_time ) - plotting_time
320- print >> sys .stderr , ('The pretraining code for file ' + os .path .split (__file__ )[1 ]+ ' ran for %.2fm expected Xm our buildbot' % (pretraining_time / 60. ))
321+ print >> sys .stderr , ('The pretraining code for file ' + os .path .split (__file__ )[1 ]+ ' ran for %.2fm expected 2.17m our buildbot' % (pretraining_time / 60. ))
321322
322323
323324 #################################
@@ -350,6 +351,9 @@ def test_rbm(learning_rate=0.1, training_epochs = 15,
350351 # until you plot at least `n_samples`
351352 n_samples = 10
352353 plot_every = 1000
354+
355+ plotting_time = 0.
356+ start_time = time .time ()
353357
354358 for idx in xrange (n_samples ):
355359
@@ -358,13 +362,20 @@ def test_rbm(learning_rate=0.1, training_epochs = 15,
358362 vis_mf , vis_sample = sample_fn ()
359363
360364 # construct image
365+ plotting_start = time .clock ()
361366 image = PIL .Image .fromarray (tile_raster_images (
362367 X = vis_mf ,
363368 img_shape = (28 ,28 ),
364369 tile_shape = (10 ,10 ),
365370 tile_spacing = (1 ,1 ) ) )
366371 print ' ... plotting sample ' , idx
367372 image .save ('sample_%i_step_%i.png' % (idx ,idx * jdx ))
373+ plotting_stop = time .clock ()
374+ plotting_time += (plotting_stop - plotting_start )
375+
376+ end_time = time .time ()
377+ sampling_time = (end_time - start_time ) - plotting_time
378+ print >> sys .stderr , ('The sampling code for file ' + os .path .split (__file__ )[1 ]+ ' ran for %.2fm expected 1.57m in our buildbot' % (sampling_time / 60. ))
368379
369380if __name__ == '__main__' :
370381 test_rbm ()
0 commit comments