I have two datasets, MNIST and SVHN.
It is known that the num. test samples of MNIST is 1000 and the num. test samples of SVHN is 26032.
Now, i want to append the test set of SVHN to MNIST, in the sense that test_set_append[9999] is the last element of MNIST, and test_set_append[10000] is the first element of SVHN.
I have already tried with the ConcatDataset:
class ConcatDataset(torch.utils.data.Dataset):
def __init__(self, *datasets):
self.datasets = datasets
def __getitem__(self, i):
return tuple(d[i] for d in self.datasets)
def __len__(self):
return min(len(d) for d in self.datasets)
But the result is not what I want:
test_set = ConcatDataset(test_set_a, test_set_b)
test_set[1]
((tensor([[[0., 0., 0., ..., 0., 0., 0.],
[0., 0., 0., ..., 0., 0., 0.],
[0., 0., 0., ..., 0., 0., 0.],
...,
[0., 0., 0., ..., 0., 0., 0.],
[0., 0., 0., ..., 0., 0., 0.],
[0., 0., 0., ..., 0., 0., 0.]]]), 2),
(tensor([[[0.5451, 0.5451, 0.5451, ..., 0.5176, 0.5216, 0.5255],
[0.5725, 0.5686, 0.5686, ..., 0.5373, 0.5333, 0.5333],
[0.6039, 0.6000, 0.6000, ..., 0.5686, 0.5569, 0.5490],
...,
[0.6196, 0.6000, 0.5804, ..., 0.3882, 0.4000, 0.4353],
[0.5843, 0.5529, 0.5216, ..., 0.3961, 0.4235, 0.4667],
[0.5569, 0.5216, 0.4824, ..., 0.4275, 0.4667, 0.5137]]]), 2))