Is there a way to predict more than one class?
Changed the final dense layer from 1 to 2 so this will return scores/probabilities for both classes. So when you use argmax, it will return the index position of the top score indicating which class it has predicted. I have solved this. I am currently working on the accuracy but the main problem is now solved.
How is one class classifier used in training?
A one-class classifier aims at capturing characteristics of training instances, in order to be able to distinguish between them and potential outliers to appear. — Page 139, Learning from Imbalanced Data Sets, 2018. A one-class classifier is fit on a training dataset that only has examples from the normal class.
When to use one class classification in data?
Once prepared, the model is used to classify new examples as either normal or not-normal, i.e. outliers or anomalies. One-class classification techniques can be used for binary (two-class) imbalanced classification problems where the negative case (class 0) is taken as “ normal ” and the positive case (class 1) is taken as an outlier or anomaly.
What could be the reason for a model predicting only one?
As pointed out already, your data may be heavily imbalanced. In such a case, the network conveniently learns to predict just 1 class to obtain a high accuracy or low loss. To tackle this, you may add new data for other classes or use weights to counter the imbalance.
Is the Keras model always predict the same class?
But keras model almost always predicts same class for all validation and test examples and the accuracy is stuck at ~50%. I have tried with a lot of different hidden layer sizes, activation functions, loss functions and optimizers but it was of no help.
How to use argmax to predict two classes?
1.Changed the class_mode to ‘categorical’ for the train and test generators 2.Changed the final dense layer from 1 to 2 so this will return scores/probabilities for both classes. So when you use argmax, it will return the index position of the top score indicating which class it has predicted.
How to always predict the same class in Python?
More generally, what I suggest to do is to print, before the parameters’ update: the value of the loss (on the same batch) either sample by sample or aggregated. And then check the same three items after the parameter update. What you should see in the next batch is a gradual change in the net output.