Skip to content

Commit 4e592ce

Browse files
committed
added rbm into the test.
1 parent 677553c commit 4e592ce

2 files changed

Lines changed: 16 additions & 5 deletions

File tree

code/rbm.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"""
77

88

9-
import numpy, time, cPickle, gzip, PIL.Image
9+
import numpy, time, cPickle, gzip, sys, os, PIL.Image
1010

1111
import theano
1212
import 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

369380
if __name__ == '__main__':
370381
test_rbm()

code/test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import convolutional_mlp, logistic_cg, logistic_sgd, mlp, SdA, dA
1+
import convolutional_mlp, logistic_cg, logistic_sgd, mlp, SdA, dA, rbm
22
from nose.plugins.skip import SkipTest
33
import theano
44
#TODO: rbm, DBN, deep
@@ -14,7 +14,7 @@ def test_convolutional_mlp():
1414
def test_dbn():
1515
raise SkipTest('Implementation not finished')
1616
def test_rbm():
17-
raise SkipTest('Implementation not finished')
17+
rbm.test_rbm(training_epochs=2)
1818
def test_dA():
1919
dA.test_dA(training_epochs = 2)
2020
def test_SdA():

0 commit comments

Comments
 (0)