comparison _test_dataset.py @ 6:d5738b79089a

Removed MinibatchIterator and instead made minibatch_size a field of all DataSets, so that they can all iterate over minibatches, optionally.
author bengioy@bengiomac.local
date Mon, 24 Mar 2008 09:04:06 -0400
parents f7dcfb5f9d5b
children 6f8f338686db
comparison
equal deleted inserted replaced
5:8039918516fe 6:d5738b79089a
11 class T_arraydataset(unittest.TestCase): 11 class T_arraydataset(unittest.TestCase):
12 def setUp(self): 12 def setUp(self):
13 numpy.random.seed(123456) 13 numpy.random.seed(123456)
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)}) 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 s+=_sum_all(example.x) 19 s+=_sum_all(example.x)
20 print s 20 print s
21 self.failUnless(abs(s-11.4674133)<1e-6) 21 self.failUnless(abs(s-11.4674133)<1e-6)
22 a.minibatch_size=2
23 for mb in a:
24 print mb
25
22 26
23 if __name__ == '__main__': 27 if __name__ == '__main__':
24 unittest.main() 28 unittest.main()
25 29