Solved by ptrblck in post #4 
              
              
                In your current code snippet you are assigning x to your complete dataset, i.e. you are performing batch gradient descent. 
In the former code your DataLoader provided batches of size 5, so you used mini-batch gradient descent. 
If you use a dataloader with batch_size=1 or slice each sample one by o…