Mercurial > pylearn
annotate 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 |
rev | line source |
---|---|
51
59757365a057
the script can be autorun
Frederic Bastien <bastienf@iro.umontreal.ca>
parents:
45
diff
changeset
|
1 #!/bin/env python |
45 | 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) | |
54 | 12 assert(len(ds)==10) |
45 | 13 print "example 0 = ",ds[0] |
54 | 14 # assert |
45 | 15 print "x=",ds["x"] |
16 print "x|y" | |
17 for x,y in ds("x","y"): | |
18 print x,y | |
19 minibatch_iterator = ds.minibatches(fieldnames=['z','y'],n_batches=1,minibatch_size=3,offset=4) | |
20 minibatch = minibatch_iterator.__iter__().next() | |
21 print "minibatch=",minibatch | |
22 for var in minibatch: | |
23 print "var=",var | |
48
b6730f9a336d
Fixing MinibatchDataSet getitem
bengioy@grenat.iro.umontreal.ca
parents:
45
diff
changeset
|
24 print "take a slice and look at field y",ds[1:6:2]["y"] |
45 | 25 |
26 test1() |