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

fix sparse acc #166

Closed roywei closed 5 years ago

roywei commented 6 years ago

Summary

Fix https://github.com/awslabs/keras-apache-mxnet/issues/165

Related Issues

https://github.com/awslabs/keras-apache-mxnet/issues/165

PR Overview

  1. 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]

  1. Not sure why max is used, but it should directly compare with y_true
  2. Added unit test to test correctness