netrack / keras-metrics

Metrics for Keras. DEPRECATED since Keras 2.3.0
MIT License
165 stars 23 forks source link

Binary classification with 2 units gives wrong precision and recall #3

Closed Avcu closed 6 years ago

Avcu commented 6 years ago

Hi, I've seen the similar issue that was about evaluation after training on multi-class classification, mine is about the training. If one has only one unit at the end, everything is correct, however if dense layer with two units is used for the last layer with a softmax activation, true positive is always equals to true negative, and false positive is always equals to false negative in every batch during the training. And when you sum all of them you obtain a number that is exactly equals to twice of batch size. Please kindly check my code below. Note: I'm aware of the fact that these metrics shouldn't be checked per batch basis, but seeing something wrong pushed me to create this issue. By the way, thanks for the library and effort.

https://colab.research.google.com/drive/1lmQ-hWcN4tsGMicd4dKnSjeTD-BdgJuE

ybubnov commented 6 years ago

@Avcu, thank you for submitting the issue, I'll try to figure out the reasons of this behavior.