comparison datasets/dataset.py @ 163:4b28d7382dbf

Add inital implementation of datasets. For the moment only nist_digits is defined.
author Arnaud Bergeron <abergeron@gmail.com>
date Thu, 25 Feb 2010 18:40:01 -0500
parents
children d6672a7daea5
comparison
equal deleted inserted replaced
162:050c7ff6b449 163:4b28d7382dbf
1 from dsetiter import DataIterator
2
3 class DataSet(object):
4 def test(self, batchsize, bufsize=None):
5 r"""
6 Returns an iterator over the test examples.
7
8 Parameters
9 batchsize (int) -- the size of the minibatches, 0 means
10 return the whole set at once.
11 bufsize (int, optional) -- the size of the in-memory buffer,
12 0 to disable.
13 """
14 return self._return_it(batchsize, bufsize, self._test)
15
16 def train(self, batchsize, bufsize=None):
17 r"""
18 Returns an iterator over the training examples.
19
20 Parameters
21 batchsize (int) -- the size of the minibatches, 0 means
22 return the whole set at once.
23 bufsize (int, optional) -- the size of the in-memory buffer,
24 0 to disable.
25 """
26 return self._return_it(batchsize, bufsize, self._train)
27
28 def valid(self, batchsize, bufsize=None):
29 r"""
30 Returns an iterator over the validation examples.
31
32 Parameters
33 batchsize (int) -- the size of the minibatches, 0 means
34 return the whole set at once.
35 bufsize (int, optional) -- the size of the in-memory buffer,
36 0 to disable.
37 """
38 return self._return_it(batchsize, bufsize, self._valid)
39
40 def _return_it(batchsize, bufsize, data):
41 r"""
42 Must return an iterator over the specified dataset (`data`).
43
44 Implement this in subclassses.
45 """
46 raise NotImplemented