What is the difference between “predict” and “pred

2020-07-02 10:36发布

问题:

What is the difference between predict and predict_class functions in keras?

Why does Model object don't have predict_class function?

回答1:

predict will return the scores of the regression and predict_class will return the class of your prediction. Although it seems similar there are some differences:

Imagine you are trying to predict if the picture is a dog or a cat (you have a classifier):

  • predict will return you: 0.6 cat and 0.2 dog (for example).
  • predict_class will return you cat

Now image you are trying to predict house prices (you have a regressor):

  • predict will return the predicted price
  • predict_class will not make sense here since you do not have a classifier

TL:DR: use predict_class for classifiers (outputs are labels) and use predict for regressions (outputs are non discrete)

Hope it helps!



回答2:

predict_classes method is only available for the Sequential class but not for the Model class You can check this answer



标签: keras