Solved by beneyal in post #2 
              
              
                Whatever is coming out of image_datasets['train'][idx] is not a tensor. You can try wrapping test_data and test_target like this: test_data = torch.tensor(test_data) and see if that works.