Well, I guess you've mixed up Probability
and Log Probability
together. While your intuition is correct that the probability value anything above or below 0-1
would have been weird. However your function isn't giving you the probabilities but the log probabilities, which is actually nothing but the probability in the logarithmic scale. So everything's good with your model.
If you're wondering why we work with log probabilities instead of probability itself, it has got to do mostly with the scaling issue, however, you could read the thread here
Example on changing Log Probabilities into Actual Probabilities:
import numpy as np
# some random log probabilities
log_probs = [-8.45855173, -7.45855173, -6.45855173, -5.45855173, -4.45855173, -3.45855173, -2.45855173, -1.45855173, -0.45855173]
# Let's turn these into actual probabilities (NOTE: If you've "negative" log probabilities, then simply negate the exponent, like np.exp(-x))
probabilities = np.exp(log_probs)
print(probabilities)
# Output:
[2.12078996e-04, 5.76490482e-04, 1.56706360e-03, 4.25972051e-03, 1.15791209e-02, 3.14753138e-02, 8.55587737e-02, 2.32572860e-01, 6.32198578e-01] # everything is between [0-1]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…