comparison 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
comparison
equal deleted inserted replaced
44:5a85fda9b19b 45:a5c70dc42972
1
2 from dataset import *
3 from math import *
4 import numpy
5
6 def test1():
7 global a,ds
8 a = numpy.random.rand(10,4)
9 print a
10 ds = ArrayDataSet(a,{'x':slice(3),'y':3,'z':[0,2]})
11 print "len(ds)=",len(ds)
12 print "example 0 = ",ds[0]
13 print "x=",ds["x"]
14 print "x|y"
15 for x,y in ds("x","y"):
16 print x,y
17 minibatch_iterator = ds.minibatches(fieldnames=['z','y'],n_batches=1,minibatch_size=3,offset=4)
18 minibatch = minibatch_iterator.__iter__().next()
19 print "minibatch=",minibatch
20 for var in minibatch:
21 print "var=",var
22 print "take a slice:",ds[1:6:2]
23
24 test1()