comparison _test_dataset.py @ 7:6f8f338686db

Moved iterating counter into a FiniteDataSetIterator to allow embedded iterations and multiple threads iterating at the same time on a dataset.
author bengioy@bengiomac.local
date Mon, 24 Mar 2008 13:20:15 -0400
parents d5738b79089a
children d1c394486037
comparison
equal deleted inserted replaced
6:d5738b79089a 7:6f8f338686db
14 14
15 def test0(self): 15 def test0(self):
16 a=ArrayDataSet(data=numpy.random.rand(8,3),fields={"x":slice(2),"y":slice(1,3)},minibatch_size=1) 16 a=ArrayDataSet(data=numpy.random.rand(8,3),fields={"x":slice(2),"y":slice(1,3)},minibatch_size=1)
17 s=0 17 s=0
18 for example in a: 18 for example in a:
19 print len(example), example.x
19 s+=_sum_all(example.x) 20 s+=_sum_all(example.x)
20 print s 21 print s
21 self.failUnless(abs(s-11.4674133)<1e-6) 22 self.failUnless(abs(s-7.25967597)<1e-6)
23
24 def test1(self):
25 a=ArrayDataSet(data=numpy.random.rand(10,4),fields={"x":slice(2),"y":slice(1,4)},minibatch_size=1)
22 a.minibatch_size=2 26 a.minibatch_size=2
27 print a.asarray()
23 for mb in a: 28 for mb in a:
29 print mb,mb.asarray()
30 print "a.y=",a.y
31 for mb in ArrayDataSet(data=a.y,minibatch_size=2):
24 print mb 32 print mb
25 33 for e in mb:
26 34 print e
35 self.failUnless(True)
36
27 if __name__ == '__main__': 37 if __name__ == '__main__':
28 unittest.main() 38 unittest.main()
29 39