|
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
|
|
|
|