Mercurial > pylearn
diff test_dataset.py @ 45:a5c70dc42972
Test functions for dataset.py
author | bengioy@grenat.iro.umontreal.ca |
---|---|
date | Tue, 29 Apr 2008 11:25:36 -0400 |
parents | |
children | b6730f9a336d 59757365a057 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test_dataset.py Tue Apr 29 11:25:36 2008 -0400 @@ -0,0 +1,24 @@ + +from dataset import * +from math import * +import numpy + +def test1(): + global a,ds + a = numpy.random.rand(10,4) + print a + ds = ArrayDataSet(a,{'x':slice(3),'y':3,'z':[0,2]}) + print "len(ds)=",len(ds) + print "example 0 = ",ds[0] + print "x=",ds["x"] + print "x|y" + for x,y in ds("x","y"): + print x,y + minibatch_iterator = ds.minibatches(fieldnames=['z','y'],n_batches=1,minibatch_size=3,offset=4) + minibatch = minibatch_iterator.__iter__().next() + print "minibatch=",minibatch + for var in minibatch: + print "var=",var + print "take a slice:",ds[1:6:2] + +test1()