Completed
Push — master ( 3e1d4c...f31f72 )
by Bart
27s
created

CalTech101Silhouettes   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %
Metric Value
dl 0
loc 33
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A data_path() 0 3 1
A __init__() 0 8 2
1
# -*- coding: utf-8 -*-
2
from fuel.utils import find_in_data_path
3
from fuel.datasets import H5PYDataset
4
5
6
class CalTech101Silhouettes(H5PYDataset):
7
    u"""CalTech 101 Silhouettes dataset.
8
9
    This dataset provides the `split1` train/validation/test split of the
10
    CalTech101 Silhouette dataset prepared by Benjamin M. Marlin [MARLIN].
11
12
    This class provides both the 16x16 and the 28x28 pixel sized version.
13
    The 16x16 version contains 4082 examples in the training set, 2257
14
    examples in the validation set and 2302 examples in the test set. The
15
    28x28 version contains 4100, 2264 and 2307 examples in the train, valid
16
    and test set.
17
18
    Parameters
19
    ----------
20
    which_sets : tuple of str
21
        Which split to load. Valid values are 'train', 'valid' and 'test'.
22
    size : {16, 28}
23
        Either 16 or 28 to select the 16x16 or 28x28 pixels version
24
        of the dataset (default: 28).
25
26
    """
27
    def __init__(self, which_sets, size=28, load_in_memory=True, **kwargs):
28
        if size not in (16, 28):
29
            raise ValueError('size must be 16 or 28')
30
31
        self.filename = 'caltech101_silhouettes{}.hdf5'.format(size)
32
        super(CalTech101Silhouettes, self).__init__(
33
            self.data_path, which_sets=which_sets,
34
            load_in_memory=load_in_memory, **kwargs)
35
36
    @property
37
    def data_path(self):
38
        return find_in_data_path(self.filename)
39