Simpletransformers: [Question] - how to interpret the raw_outputs in binary classification

Created on 30 May 2020  路  4Comments  路  Source: ThilinaRajapakse/simpletransformers

Hi !

What mean the raw_outputs from the predict() function in binary classification ?
Can we make a probability with the output ?
Exemple of output :

[[-0.45289087  0.49692678]
 [ 3.3066     -2.8679602 ]]

I use a bert-base-multilingual-cased fine-tun.
I don't find some documentation about that..

Thank you in advance

Most helpful comment

These are scores from the model. You basically just need to apply a softmax on it and you'll get probabilities. Something like this:

from scipy.special import softmax
probabilities = np.array([softmax(element) for element in model_outputs])

All 4 comments

These are scores from the model. You basically just need to apply a softmax on it and you'll get probabilities. Something like this:

from scipy.special import softmax
probabilities = np.array([softmax(element) for element in model_outputs])

Hi @mananeau sorry for my late reply and thanks to answer me.

Well done it's look like what I want, but I have some question about the ouput...

the output of my model is :
[ 3.473154 -2.9149506 ]
and after softmax function is look like that: [ 0.9983213 0.00167862 ]

What mean the two output value of the model ?
and for the softmax function which one is the right percentage value ?

Do you know where can I find some documentation about the output of the model ?

Thank for all :+1:

The two outputs (after softmax) are the probabilities for each of the two binary labels. In your example, the model is giving a 99.83213% probability for label 0 and 0.167862% probability for label 1.

There is no specific documentation regarding this particular question as this is not specific to Simple Transformers.

Hi @ThilinaRajapakse, Thanks for your answer !

Yes it's not specific to Simple Transformers but specific to the model
I find the answer about the output of the model, in the code here

So the output of BERT model is a Logit, this, let me more understand about why we use a softmax function

Thanks for all :+1:

Was this page helpful?
0 / 5 - 0 ratings