I have trained the pretrained Resnet model 18 for binary classification. I use this function to predict a single image:
def predict_image(image):
image_tensor = test_transforms(image).float()
print(image_tensor.shape)
image_tensor = image_tensor.unsqueeze_(0)
print(image_tensor.shape)
input = Variable(image_tensor)
input = input.to(device)
output = model(input)
index = output.data.cpu().numpy()
return index
This prints
torch.Size([3, 224, 224])
torch.Size([1, 3, 224, 224])
[[-0.30215618 0.21753347]]
Shouldn’t the probabilities sum to 1, What does a negative probability mean here ?