Thanks, it’s more clear now. But it seems like getitem is not defined properly, it fails to access self.MNIST, as MyDataset has no MNIST attribute.

if index < self.MNIST:

AttributeError: Traceback (most recent call last):
File “/home/nimrod/anaconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py”, line 57, in _worker_loop
samples = collate_fn([dataset[i] for i in batch_indices])
File “/home/nimrod/anaconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py”, line 57, in 
samples = collate_fn([dataset[i] for i in batch_indices])
File “”, line 27, in getitem
if index < self.MNIST:
AttributeError: ‘MyDataset’ object has no attribute ‘MNIST’
I tried to replace self.MNIST with self.mnist_len but it didn’t help, I get that MNIST object is not callable:
TypeError: Traceback (most recent call last):
File “/home/nimrod/anaconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py”, line 57, in _worker_loop
samples = collate_fn([dataset[i] for i in batch_indices])
File “/home/nimrod/anaconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py”, line 57, in 
samples = collate_fn([dataset[i] for i in batch_indices])
File “”, line 30, in getitem
x = self.mnist_transform(x)
TypeError: ‘MNIST’ object is not callable