且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

keras:model.predict和model.predict_proba有什么区别

更新时间:2023-12-02 14:39:22

预测

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

生成输入样本的输出预测,以批处理方式处理样本。

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

参数

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

返回

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.

参数

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.

返回

A Numpy array of probability predictions.

编辑:在最新版本的keras中,predict和predict_proba相同即都给出概率。要获取类标签,请使用predict_classes。该文档未更新。 (根据Avijit Dasgupta的评论改编)

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)