Solved by saty_101 in post #2 
              
              
                I was able to solve this problem by using this code, putting the code here if anyone else is stuck. 
train_x = torch.cat([torch.stack([tensor(Image.open(o)) for o in ((path_digits[i])]).float()/255 for i in range(10)])