awslabs / keras-apache-mxnet

[DEPRECATED] Amazon Deep Learning's Keras with Apache MXNet support
https://github.com/awslabs/keras-apache-mxnet/wiki
Other
290 stars 65 forks source link

bug in sparse_categorical_accuracy #165

Closed roywei closed 6 years ago

roywei commented 6 years ago

sparse categorical acc should have the same result as categorical acc.

For example, with 3 classes, given sparse_true_label = [0, 1, 1], it's equivalent in categorical labels is dense_true_label = [[1, 0, 0], [0, 1, 0], [0, 1, 0]]. With the same predictions

pred = [[0.7, 0.2, 0.1], 
[0.1, 0.1, 0.8], 
[0.2, 0.6, 0.2]]

They should produce the same acc which is [1, 0 ,1]

The current implementation use max operator and produce a wrong output [0, 0, 1]

roywei commented 6 years ago

Also submitted PR to keras team: https://github.com/keras-team/keras/pull/11100