Solved by LeviViana in post #2 
              
              
                x1 = np.array([1,2,3]) isn’t a Dataset as properly defined by PyTorch. Actually, Dataset is just a very simple abstract class (pure Python). 
Indeed, the snippet below works as expected, i.e., it will sample correctly: 
import torch
import numpy as np
x = np.arange(6)
d = DataLoader(x, batch_size=2)…