Skip to content

Commit 223e870

Browse files
committed
moved the timing into the code to time only the exec time.
1 parent 5c9a443 commit 223e870

10 files changed

Lines changed: 25 additions & 39 deletions

File tree

code/DBN.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,8 +299,7 @@ def test_DBN( finetune_lr = 0.1, pretraining_epochs = 10, \
299299
print 'Pre-training layer %i, epoch %d, cost '%(i,epoch),numpy.mean(c)
300300

301301
end_time = time.clock()
302-
303-
print ('Pretraining took %f minutes' %((end_time-start_time)/60.))
302+
print >> sys.stderr, ('The pretraining code for file '+os.path.split(__file__)[1]+' ran for %.2fm expected Xm our buildbot' % ((end_time-start_time)/60.))
304303

305304
########################
306305
# FINETUNING THE MODEL #
@@ -379,7 +378,7 @@ def test_DBN( finetune_lr = 0.1, pretraining_epochs = 10, \
379378
print(('Optimization complete with best validation score of %f %%,'
380379
'with test performance %f %%') %
381380
(best_validation_loss * 100., test_score*100.))
382-
print ('The code ran for %f minutes' % ((end_time-start_time)/60.))
381+
print >> sys.stderr, ('The fine tuning code for file '+os.path.split(__file__)[1]+' ran for %.2fm expected Xm our buildbot' % ((end_time-start_time)/60.))
383382

384383

385384

code/SdA.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
3131
"""
3232

33-
import numpy, time, cPickle, gzip
33+
import numpy, time, cPickle, gzip, sys, os
3434

3535
import theano
3636
import theano.tensor as T
@@ -351,7 +351,7 @@ def test_SdA( finetune_lr = 0.1, pretraining_epochs = 15, \
351351

352352
end_time = time.clock()
353353

354-
print ('Pretraining took %f minutes' %((end_time-start_time)/60.))
354+
print >> sys.stderr, ('The pretraining code for file '+os.path.split(__file__)[1]+' ran for %.2fm expected 4.58m in our buildbot' % ((end_time-start_time)/60.))
355355

356356
########################
357357
# FINETUNING THE MODEL #
@@ -428,7 +428,7 @@ def test_SdA( finetune_lr = 0.1, pretraining_epochs = 15, \
428428
print(('Optimization complete with best validation score of %f %%,'
429429
'with test performance %f %%') %
430430
(best_validation_loss * 100., test_score*100.))
431-
print ('The code ran for %f minutes' % ((end_time-start_time)/60.))
431+
print >> sys.stderr, ('The training code for file '+os.path.split(__file__)[1]+' ran for %.2fm expected 3.91m in our buildbot' % ((end_time-start_time)/60.))
432432

433433

434434

code/convolutional_mlp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
http://yann.lecun.com/exdb/publis/pdf/lecun-98.pdf
1919
"""
2020

21-
import numpy, time, cPickle, gzip
21+
import numpy, time, cPickle, gzip, sys, os
2222

2323
import theano
2424
import theano.tensor as T
@@ -283,7 +283,7 @@ def evaluate_lenet5(learning_rate=0.1, n_epochs=200, dataset='mnist.pkl.gz', nke
283283
print('Best validation score of %f %% obtained at iteration %i,'\
284284
'with test performance %f %%' %
285285
(best_validation_loss * 100., best_iter, test_score*100.))
286-
print('The code ran for %f minutes' % ((end_time-start_time)/60.))
286+
print >> sys.stderr, ('The code for file '+os.path.split(__file__)[1]+' ran for %.2fm expected 2.51m in our buildbot' % ((end_time-start_time)/60.))
287287

288288
if __name__ == '__main__':
289289
evaluate_lenet5()

code/dA.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
3131
"""
3232

33-
import numpy, time, cPickle, gzip
33+
import numpy, time, cPickle, gzip, sys, os
3434

3535
import theano
3636
import theano.tensor as T
@@ -282,8 +282,7 @@ def test_dA( learning_rate = 0.1, training_epochs = 15, dataset ='mnist.pkl.gz'
282282

283283
training_time = (end_time - start_time)
284284

285-
print ('Training took %f minutes' %(training_time/60.))
286-
285+
print >> sys.stderr, ('The no corruption code for file '+os.path.split(__file__)[1]+' ran for %.2fm expected 1.17m our buildbot' % ((training_time)/60.))
287286
image = PIL.Image.fromarray(tile_raster_images( X = da.W.value.T,
288287
img_shape = (28,28),tile_shape = (10,10),
289288
tile_spacing=(1,1)))
@@ -325,7 +324,7 @@ def test_dA( learning_rate = 0.1, training_epochs = 15, dataset ='mnist.pkl.gz'
325324

326325
training_time = (end_time - start_time)
327326

328-
print ('Training took %f minutes' %(training_time/60.))
327+
print >> sys.stderr, ('The 30% corruption code for file '+os.path.split(__file__)[1]+' ran for %.2fm expected 1.18m our buildbot' % (training_time/60.))
329328

330329
image = PIL.Image.fromarray(tile_raster_images( X = da.W.value.T,
331330
img_shape = (28,28),tile_shape = (10,10),

code/deep.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ def dbn_main(finetune_lr = 0.01,
577577
(28,28), (10,10),
578578
tile_spacing=(1,1))).save('filters_%i_%i.png'%(layer_idx,i))
579579
end_time = time.clock()
580-
print 'Pretraining took %f minutes' %((end_time - start_time)/60.)
580+
print >> sys.stderr, ('The pretraining code for file '+os.path.split(__file__)[1]+' ran for %.2fm expected Xm our buildbot' % (((end_time - start_time))/60.))
581581

582582
return
583583

@@ -644,7 +644,8 @@ def dbn_main(finetune_lr = 0.01,
644644
'with test performance %f %%') %
645645
(finetune_status['best_validation_loss']*100.,
646646
finetune_status['test_score']*100.))
647-
print ('The code ran for %f minutes' % ((finetune_status['duration'])/60.))
647+
print >> sys.stderr, ('The fine tuning code for file '+os.path.split(__file__)[1]+' ran for %.2fm expected Xm our buildbot' % ((end_time-start_time)/60.))
648+
648649

649650
def rbm_main():
650651
rbm = RBM(n_visible=20, n_hidden=30,

code/logistic_cg.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
__docformat__ = 'restructedtext en'
3838

3939

40-
import numpy, time, cPickle, gzip
40+
import numpy, time, cPickle, gzip, sys, os
4141

4242
import theano
4343
import theano.tensor as T
@@ -302,7 +302,7 @@ def callback(theta_value):
302302
'test performance %f %%') %
303303
(validation_scores[0]*100., validation_scores[1]*100.))
304304

305-
print ('The code ran for %f minutes' % ((end_time-start_time)/60.))
305+
print >> sys.stderr, ('The code for file '+os.path.split(__file__)[1]+' ran for %.1fs expected 6.8s in our buildbot' % ((end_time-start_time)))
306306

307307

308308
if __name__ == '__main__':

code/logistic_sgd.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"""
3636
__docformat__ = 'restructedtext en'
3737

38-
import numpy, time, cPickle, gzip
38+
import numpy, time, cPickle, gzip, sys, os
3939

4040
import theano
4141
import theano.tensor as T
@@ -341,7 +341,7 @@ def sgd_optimization_mnist(learning_rate=0.13, n_epochs=1000, dataset='mnist.pkl
341341
print(('Optimization complete with best validation score of %f %%,'
342342
'with test performance %f %%') %
343343
(best_validation_loss * 100., test_score*100.))
344-
print ('The code ran for %f minutes' % ((end_time-start_time)/60.))
344+
print >> sys.stderr, ('The code for file '+os.path.split(__file__)[1]+' ran for %.1fs expected 3.8s in our buildbot' % ((end_time-start_time)))
345345

346346
if __name__ == '__main__':
347347
sgd_optimization_mnist()

code/mlp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
__docformat__ = 'restructedtext en'
2222

2323

24-
import numpy, time, cPickle, gzip
24+
import numpy, time, cPickle, gzip, sys, os
2525

2626
import theano
2727
import theano.tensor as T
@@ -347,7 +347,7 @@ def test_mlp( learning_rate=0.01, L1_reg = 0.00, L2_reg = 0.0001, n_epochs=1000,
347347
print(('Optimization complete. Best validation score of %f %% '
348348
'obtained at iteration %i, with test performance %f %%') %
349349
(best_validation_loss * 100., best_iter, test_score*100.))
350-
print ('The code ran for %f minutes' % ((end_time-start_time)/60.))
350+
print >> sys.stderr, ('The code for file '+os.path.split(__file__)[1]+' ran for %.2fm expected 1.51m in our buildbot' % ((end_time-start_time)/60.))
351351

352352

353353
if __name__ == '__main__':

code/rbm.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,7 @@ def test_rbm(learning_rate=0.1, training_epochs = 15,
317317
end_time = time.clock()
318318

319319
pretraining_time = (end_time - start_time) - plotting_time
320-
321-
print ('Training took %f minutes' %(pretraining_time/60.))
320+
print >> sys.stderr, ('The pretraining code for file '+os.path.split(__file__)[1]+' ran for %.2fm expected Xm our buildbot' % (pretraining_time/60.))
322321

323322

324323
#################################

code/test.py

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,21 @@
1-
#import convolutional_mlp, dbn, logistic_cg, logistic_sgd, mlp, rbm, SdA_loops, SdA
21
import convolutional_mlp, logistic_cg, logistic_sgd, mlp, SdA, dA
32
from nose.plugins.skip import SkipTest
4-
import time,sys
5-
#TODO: dbn, rbm, SdA, SdA_loops, convolutional_mlp
3+
import theano
4+
#TODO: rbm, DBN, deep
5+
66
def test_logistic_sgd():
7-
t0=time.time()
87
logistic_sgd.sgd_optimization_mnist(n_epochs=10)
9-
print >> sys.stderr, "test_logistic_sgd took %.3fs expected 15.2s in our buildbot"%(time.time()-t0)
108
def test_logistic_cg():
11-
t0=time.time()
129
logistic_cg.cg_optimization_mnist(n_epochs=10)
13-
print >> sys.stderr, "test_logistic_cg took %.3fs expected 14s in our buildbot"%(time.time()-t0)
1410
def test_mlp():
15-
t0=time.time()
1611
mlp.test_mlp(n_epochs=5)
17-
print >> sys.stderr, "test_mlp took %.3fs expected 118s in our buildbot"%(time.time()-t0)
1812
def test_convolutional_mlp():
19-
t0=time.time()
2013
convolutional_mlp.evaluate_lenet5(n_epochs=5,nkerns=[5,5])
21-
print >> sys.stderr, "test_convolutional_mlp took %.3fs expected 168s in our buildbot"%(time.time()-t0)
2214
def test_dbn():
2315
raise SkipTest('Implementation not finished')
2416
def test_rbm():
2517
raise SkipTest('Implementation not finished')
2618
def test_dA():
27-
t0=time.time()
28-
dA.test_dA(training_epochs = 3)
29-
print >> sys.stderr, "test_dA took %.3fs expected Xs in our buildbot"%(time.time()-t0)
19+
dA.test_dA(training_epochs = 2)
3020
def test_SdA():
31-
t0=time.time()
32-
SdA.test_SdA(pretraining_epochs = 2, training_epochs = 3)
33-
print >> sys.stderr, "test_SdA took %.3fs expected 971s in our buildbot"%(time.time()-t0)
21+
SdA.test_SdA(pretraining_epochs = 1, training_epochs = 2)

0 commit comments

Comments
 (0)