Mercurial > pylearn
changeset 727:d57df00f12b0
Fixed test_speed test
I had to delete some mini-batch test, that was somehow trying to do something
like
some_list + 1
and thus Python was not happy because '+' means list concatenation... I am not
sure what was the intent of this thing, so I removed it.
author | Olivier Delalleau <delallea@iro> |
---|---|
date | Wed, 27 May 2009 11:48:05 -0400 |
parents | 2014db81b9bc |
children | 71a052a92b05 |
files | pylearn/sandbox/test_speed.py |
diffstat | 1 files changed, 22 insertions(+), 19 deletions(-) [+] |
line wrap: on
line diff
--- a/pylearn/sandbox/test_speed.py Wed May 27 11:46:08 2009 -0400 +++ b/pylearn/sandbox/test_speed.py Wed May 27 11:48:05 2009 -0400 @@ -1,7 +1,17 @@ -import numpy +import numpy, time from pylearn.datasets import * -from misc import * -def test_speed(array, ds): +#from misc import * +from pylearn.old_dataset.dataset import ArrayDataSet, CachedDataSet +from pylearn.old_dataset.lookup_list import LookupList + +def print_timing(f): + def new_f(*lst, **kw): + start = time.time() + f(*lst, **kw) + print "Time elapsed: %s" % (time.time() - start) + return new_f + +def run(array, ds): print "test_speed", ds.__class__ mat = numpy.random.rand(400,100) @@ -40,12 +50,6 @@ # pass ex[0]+1 # ex[0]*mat - @print_timing - def f_ds_mb2(ds,mb_size): - for exs in ds.minibatches(minibatch_size = mb_size): -# pass - exs[0]+1 -# ex[0]*mat f_array_full(array) f_array_index(array) @@ -58,22 +62,21 @@ f_ds_mb1(ds,100) f_ds_mb1(ds,1000) f_ds_mb1(ds,10000) - f_ds_mb2(ds,10) - f_ds_mb2(ds,100) - f_ds_mb2(ds,1000) - f_ds_mb2(ds,10000) -if __name__=='__main__': +def test_speed(): a2 = numpy.random.rand(100000,400) ds1 = ArrayDataSet(a2,{'all':slice(0,a2.shape[1],1)}) - test_speed(a2,ds1) + run(a2,ds1) a1 = numpy.random.rand(100000,40) ds4 = ArrayDataSet(a1,LookupList(["f"+str(x)for x in range(a1.shape[1])], range(a1.shape[1]))) - test_speed(a2,ds4) + run(a2,ds4) ds2=CachedDataSet(ds1,cache_all_upon_construction=False) - test_speed(a2,ds2) + run(a2,ds2) + del ds2 ds3=CachedDataSet(ds1,cache_all_upon_construction=True) - test_speed(a2,ds3) - del a2,ds1,ds2,ds3 + run(a2,ds3) + del a2,ds1,ds3 +if __name__=='__main__': + test_speed()