Mercurial > pylearn
view test_dataset.py @ 54:70147d00615a
added assert
author | Frederic Bastien <bastienf@iro.umontreal.ca> |
---|---|
date | Tue, 29 Apr 2008 16:06:50 -0400 |
parents | e3ac93e27e16 |
children | 17729d7104fa |
line wrap: on
line source
#!/bin/env python 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) assert(len(ds)==10) print "example 0 = ",ds[0] # assert 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 and look at field y",ds[1:6:2]["y"] test1()