Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor) should be the same

I moved my model to gpu

but when i try to test the model , as per the
Pytorch tutorial

dataiter = iter(testloader)
images, labels =

print('GroundTruth: ', ' '.join('%5s' % classes[labels[j]] for j in range(4)))

outputs = net(images)  #This line throws the error

what is the issue ???

1 Like

You need to pass images to device also.

pass images to device by using below code

dataiter = iter(testloader)
images, labels =
images,labels =,

Thanks man , it worked

I have a problem. i mounted my data on google drive and when i want to train my model it has an issue same as below:

Make sure to push the input data to the device using:

input = input.cuda()
# or
input ='cuda')

thankyou so much. it helped.

‫‪ptrblck via PyTorch Forums‬‏ <‪‬‏> در تاریخ دوشنبه ۶ آوریل ۲۰۲۰ ساعت ۸:۱۰ نوشت:‬