TypeError: conv2d() received an invalid combination of arguments - got (torch.device, Parameter, NoneType, tuple, tuple, tuple, int), but expected one of:

Dear concern,
I need help with calling the trained model and getting prediction results from it. I really appreciate any help you can provide.

def get_prediction(model, dataloader):
    with torch.no_grad():
        model = model.to(device)
        model.eval()
        prediction = np.zeros(len(dataloader.dataset))
        labels = np.zeros(len(dataloader.dataset))
        k = 0
        for images, target in dataloader:
            if device:
                images = images.type(torch.cuda.FloatTensor)
                images = images.device
            prediction[k:k+len(images)] = np.argmax(model(images).data.cpu().numpy(), axis=1)
            labels[k:k+len(images)] = target.numpy()
            k += len(images)
    return prediction, labels

pred = get_prediction(model, valid_loader)

You are overriding the images tensor with its device attribute in:

images = images.device

and try to pass it to the model.
Pass the tensors instead and it should work.

Thanks a lot @ptrblck