Customized-DataLoader-pytorch icon indicating copy to clipboard operation
Customized-DataLoader-pytorch copied to clipboard

Couldn't Convert Logits to Probabilities

Open agnonchik opened this issue 7 years ago • 2 comments

Hi Jiangzy,

Can you help me to convert output of your model to probability? For example, after three epochs, I've got zero loss for a test mini-batch:

Ground truth: Variable containing: 0 0 1 0 0 1 0 0 0 0 0 0 0 0 1 0 0 1 0 0 [torch.cuda.LongTensor of size 4x5 (GPU 0)]

MultiLabelNN output: Variable containing: 1.5470 1.2482 -1.0002 -0.9878 -0.9223 1.1135 0.9233 -0.7197 -0.7006 -0.6467 1.9094 1.5543 -1.2340 -1.1795 -1.0985 1.2281 1.0065 -0.8014 -0.7568 -0.7007 [torch.cuda.FloatTensor of size 4x5 (GPU 0)]

Testing Phase: Epoch: [124][ 2/ 3] Iteration Loss: 0.000000e+00

How can I convert "1.5470 1.2482 -1.0002 -0.9878 -0.9223" to probabilities???

If I apply Softmax to the NN output, I will get "0.4000 0.3517 0.0826 0.0829 0.0829" for the first row which is not consistent with the corresponding ground truth "0 0 1 0 0". Nevertheless, the loss is zero! Why? I cannot understand this. For the given ground truth "0 0 1 0 0", I expect maximum probability to be at the third (not at the first) position of Softmax output vector. Am I wrong?

So, my question is how to make predictions out of NN output (e.g. "1.5470 1.2482 -1.0002 -0.9878 -0.9223)?

Please help. Val.

agnonchik avatar Sep 28 '18 15:09 agnonchik

I have solved the problem by converting hot vectors to indices.

agnonchik avatar Oct 02 '18 14:10 agnonchik

I have solved the problem by converting hot vectors to indices.

HI, agnonchik

how to convert? Thanks.

steveyi168 avatar Jun 10 '20 09:06 steveyi168