Keras: model.evaluate vs model.predict accuracy difference in multi-class NLP task

前端 未结 1 1007
囚心锁ツ
囚心锁ツ 2020-12-02 14:50

I am training a simple model in keras for NLP task with following code. Variable names are self explanatory for train, test and validation set. This dataset has 19 classes s

1条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-02 15:17

    I have found the problem. metrics=['accuracy'] calculates accuracy automatically from cost function. So using binary_crossentropy shows binary accuracy, not categorical accuracy. Using categorical_crossentropy automatically switches to categorical accuracy and now it is the same as calculated manually using model1.predict(). Yu-Yang was right to point out the cost function and activation function for multi-class problem.

    P.S: One can get both categorical and binary accuracy by using metrics=['binary_accuracy', 'categorical_accuracy']

    0 讨论(0)
提交回复
热议问题