keras: what is the difference between model.predict and model.predict_proba

前端 未结 3 940
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-03 23:27

I found model.predict and model.predict_proba both give an identical 2D matrix representing probabilities at each categories for each row.

Wha

3条回答
  •  生来不讨喜
    2021-02-04 00:03

    predict

    predict(self, x, batch_size=32, verbose=0)
    

    Generates output predictions for the input samples, processing the samples in a batched way.

    Arguments

    x: the input data, as a Numpy array.
    batch_size: integer.
    verbose: verbosity mode, 0 or 1.
    

    Returns

    A Numpy array of predictions.
    

    predict_proba

    predict_proba(self, x, batch_size=32, verbose=1)
    

    Generates class probability predictions for the input samples batch by batch.

    Arguments

    x: input data, as a Numpy array or list of Numpy arrays (if the model has multiple inputs).
    batch_size: integer.
    verbose: verbosity mode, 0 or 1.
    

    Returns

    A Numpy array of probability predictions.
    

    Edit: In the recent version of keras, predict and predict_proba is same i.e. both give probabilities. To get the class labels use predict_classes. The documentation is not updated. (adapted from Avijit Dasgupta's comment)

提交回复
热议问题