Tensorflow always predicts 0

2019-09-19 14:50发布

问题:

I'm trying to train a NN for binary classification but using multi-class approach, hence Class (C) =2. The accuracy on both train and test data sets is ~ 96%. However, manual checking reveals that Tensorflow always picks 0 for every example.

I'm interested in knowing how to go about debugging this issue and what I am doing wrong. Greatly appreciate your help. Thanks.

(Please let me know if I'm being too vague and not providing enough info in order for you to pinpoint a good solution. Thanks.)

回答1:

If you have 96% accuracy and all predictions are 0 then your dataset is probably imbalanced. You should balance it and make the number of samples from the positive and negative classes the same. You can also add weights for the class, penalizing more the class with less samples.