In the code below:
model_ft.eval()
test_data, test_target = image_datasets[\'train\'][idx]
test_data = test_data.cuda()
#test_target = test_targe
Here's the fix:
test_data, test_target = image_datasets['train'][idx]
test_data = test_data.cuda()
test_target = torch.tensor(test_target)
test_target = test_target.cuda()
test_data.unsqueeze_(0)
test_target.unsqueeze_(0)
output = model_ft(test_data)
I had to change test_data.unsqueeze_(1)
to test_data.unsqueeze_(0)