0

I currently use a keras model for text classification. Calling the evaluate method I often have accuracies around 90 percent. However, calling the predict function and printing the output does not seem interpretable to me. I am using binary_crossentropy. I do not know which value will trigger the neurons to be active, or how to see that at all. I attached some outputs(the binary ones are the actual classes). How does evaluate compute the accuracy?

[0 0 0 0 0 0 1 0 0 0 0 0 0 0 0]

[0.02632797 0.02205164 0.00884359 0.00948936 0.21821289 0.02533042
 0.07450009 0.01911888 0.22753781 0.00904192 0.0023979  0.03065717
 0.0049532  0.09980826 0.0047154 ]


[1 0 0 0 0 0 0 0 1 0 0 0 0 0 0]

[0.17915486 0.1063956  0.05139401 0.01718497 0.06058983 0.11605757
 0.11845534 0.03865225 0.6665891  0.01648878 0.02570258 0.14659531
 0.01044943 0.04226198 0.02007598]


[1 0 0 0 0 0 0 0 1 0 0 0 0 0 0]

[0.07659172 0.07020403 0.00733146 0.01322867 0.43747708 0.02796873
 0.03419256 0.03095324 0.15433209 0.02747604 0.01686232 0.0165229
 0.0226498  0.01947697 0.07312528]
James
  • 2,843
  • 1
  • 14
  • 24
Rami
  • 43
  • 6
  • The differences between evaluate() and predict() have been discussed [here](https://stackoverflow.com/questions/44476706/difference-between-keras-model-evaluate-and-model-predict). – DocDriven May 25 '18 at 08:21

1 Answers1

0

Use 'categorical_crossentropy' instead of 'binary_crossentropy'.

Check if you are normalizing the training data (for example X_train/255) and not normalizing the test data.

  • Thanks. No, that is not solving the problem. Refer: https://github.com/keras-team/keras/issues/2166. Input could have multiple labels. The problem is rather the sparsity of my code. I am going to open a new question since my current question seems to be not understood correctly. – Rami May 25 '18 at 18:28