keras:model.predict和model.predict_proba有什么区别 [英] keras: what is the difference between model.predict and model.predict_proba

查看:1079
本文介绍了keras:model.predict和model.predict_proba有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现 model.predict model.predict_proba 都给出了相同的2D矩阵,表示每个类别的概率每一行。

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

这两个函数有什么区别?

What is the difference of the two functions?

推荐答案

预测

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)

这篇关于keras:model.predict和model.predict_proba有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆