I have trained a network with the following structure:
Intent_LSTM(
(attention): Attention()
(embedding): Embedding(34601, 400)
(lstm): LSTM(400, 512, num_layers=2, batch_first=True, dropout=0.5)
(dropout): Dropout(p=0.5, inplace=False)
(fc): Linear(in_features=512, out_features=3, bias=True)
)
Now I want to test this trained network and also get the confidence score of classification. Here is my current implementation of test function:
output = model_current(inputs)
pred = torch.round(output.squeeze())
pred = pred.argmax(dim=1, keepdim=True)
Now my question isas follows.
Here pred is just the output from a Fully connected layer from my network without softmax (as required by a loss function). Is this(pred = pred.argmax(dim=1, keepdim=True)) the right way to get the predictions? Or should I pass the output from the network to a softmax layer and then do argmax?
How do I get the confidence score? Should I pass the output from the network to a softmax layer and select the argmax as the confidence of the class?
argmax
before or after doing softmax. Because whatever maximizes softmax will also maximize the logits (pre-softmax) values. So you should get similar values.