Assignment 9 - data training: error when trying to evaluate a model #13
-
Hello, could someone guide me in the right direction. I don't understand what is wrong with my code. Thank you! ` device = torch.device("cuda" if torch.cuda.is_available() else "cpu") img_array = imread(train_imageinfo_list[0][0]) channel_adder = AddChannel() mymodel = build_model(arch = "vgg16", pretrained = False).to(device)
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This is caused by the input having a different data type as model weights. I would suggest adding this line just before building your model: img = img.float() This will convert your image tensor into |
Beta Was this translation helpful? Give feedback.
This is caused by the input having a different data type as model weights. I would suggest adding this line just before building your model:
This will convert your image tensor into
float
data type, which is the same as your model weight data type.