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

前端 未结 2 1446
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-03 22:35

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

Why does Model object don\'t have predict_c

相关标签:
2条回答
  • 2021-01-03 23:03

    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.4 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!

    For your second question, the answer is here

    0 讨论(0)
  • 2021-01-03 23:05

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

    0 讨论(0)
提交回复
热议问题