Skip to content

Commit 72eac47

Browse files
committed
Add SVHN to the datasets.
1 parent 97ecd3b commit 72eac47

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

DeepFried2/datasets/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
from . import cifar100
44
from . import sequence_sum
55
from . import stanfordbg
6+
from . import svhn2
67
from . import timeseries

DeepFried2/datasets/svhn2.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from DeepFried2.zoo.download import download as _download
2+
3+
import numpy as _np
4+
import scipy.io as _sio
5+
6+
7+
def data():
8+
fname_train = _download('http://ufldl.stanford.edu/housenumbers/train_32x32.mat')
9+
fname_test = _download('http://ufldl.stanford.edu/housenumbers/test_32x32.mat')
10+
fname_extra = _download('http://ufldl.stanford.edu/housenumbers/extra_32x32.mat')
11+
12+
def loadxy(fname):
13+
mat = _sio.loadmat(fname)
14+
X = mat['X'].transpose(3, 2, 0, 1).astype(_np.float32)
15+
X /= 255
16+
y = mat['y'][:,0].astype(_np.int64) # For convenience/avoid stupid bugs.
17+
return X, y
18+
19+
return loadxy(fname_train), loadxy(fname_test), loadxy(fname_extra)
20+

0 commit comments

Comments
 (0)