<SYSTEM_TASK:>
Given the following text problem statement, write Python code to implement the functionality described below in problem statement
<END_TASK>
<USER_TASK:>
Problem:
I have a trained PyTorch model and I want to get the confidence score of predictions in range (0-1). The code below is giving me a score but its range is undefined. I want the score in a defined range of (0-1) using softmax. Any idea how to get this?
<ASSISTANT_TASK:>
Python Code:
import numpy as np
import pandas as pd
import torch
MyNet = torch.nn.Sequential(torch.nn.Linear(4, 15),
                            torch.nn.Sigmoid(),
                            torch.nn.Linear(15, 3),
                            )
MyNet.load_state_dict(torch.load("my_model.pt"))
input = load_data()
assert type(input) == torch.Tensor
'''
training part
'''
# X, Y = load_iris(return_X_y=True)
# lossFunc = torch.nn.CrossEntropyLoss()
# opt = torch.optim.Adam(MyNet.parameters(), lr=0.001)
# for batch in range(0, 50):
#     for i in range(len(X)):
#         x = MyNet(torch.from_numpy(X[i]).float()).reshape(1, 3)
#         y = torch.tensor(Y[i]).long().unsqueeze(0)
#         loss = lossFunc(x, y)
#         loss.backward()
#         opt.step()
#         opt.zero_grad()
#         # print(x.grad)
#         # print(loss)
#     # print(loss)
output = MyNet(input)
probs = torch.nn.functional.softmax(output.reshape(1, 3), dim=1)
confidence_score, classes = torch.max(probs, 1)
<END_TASK>