Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion torchvision/datasets/svhn.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,16 @@ def __init__(self, root, split='train',
loaded_mat = sio.loadmat(os.path.join(root, self.filename))

self.data = loaded_mat['X']
self.labels = loaded_mat['y']
# loading from the .mat file gives an np array of type np.uint8
# converting to np.int64, so that we have a LongTensor after
# the conversion from the numpy array
# the squeeze is needed to obtain a 1D tensor
self.labels = loaded_mat['y'].astype(np.int64).squeeze()

# the svhn dataset assigns the class label "10" to the digit 0
# this makes it inconsistent with several loss functions
# which expect the class labels to be in the range [0, C-1]
np.place(self.labels, self.labels == 10, 0)

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

self.data = np.transpose(self.data, (3, 2, 0, 1))

def __getitem__(self, index):
Expand Down