How to get the predict probability?
This code get the 1 or 0 value from model. 
If I want to get the probability of the prediction 
Which line should I change?

from torch.autograd import Variable
results = []
#names = []
with torch.no_grad():
    model.eval()
    print('===============================================start')
    for num, data in enumerate(test_loader):
        #print(num)
        print("=====================================================")

        imgs, label = data
        imgs,labels = imgs.to(device), label.to(device)
        test = Variable(imgs)
        output = model(test)
        #print(output)
        ps = torch.exp(output)
        print(ps)
        top_p, top_class = ps.topk(1, dim = 1)
        results += top_class.cpu().numpy().tolist()



model = models.resnet50(pretrained=True)
model.fc = nn.Linear(2048, num_classes)
model.cuda()


Models usually outputs raw prediction logits. To convert them to probability you should use softmax function
import torch.nn.functional as nnf

# ...
prob = nnf.softmax(output, dim=1)

top_p, top_class = prob.topk(1, dim = 1)

new variable top_p should give you the probability of the top k classes.
