问题描述
我正在训练一个模型,该模型需要报告类概率,而不是单个分类.我有三个班级,每个训练实例都分配有三个班级之一.
I am training a model for which I need to report class probabilities instead of a single classification. I have three classes and each training instance has either of the three classes assigned to it.
我正在尝试使用Keras创建MLP.但是我不知道如何为每个班级提取最终班级的概率.我以此为基本示例: http://machinelearningmastery.com /regression-tutorial-keras-deep-learning-library-python/
I am trying to use Keras to create an MLP. But I can't figure how to extract the final class probabilities for each class. I am using this as my base example: http://machinelearningmastery.com/regression-tutorial-keras-deep-learning-library-python/
谢谢!
推荐答案
您可以使用受训模型的预测方法
You could use the predict method of your trained model
predict(self,x,batch_size = 32,verbose = 0)
predict(self, x, batch_size=32, verbose=0)
为输入样本生成输出预测,以批处理方式处理样本 方式.
Generates output predictions for the input samples, processing the samples in a batched way.
参数
x:输入数据,作为一个Numpy数组(或Numpy数组的列表,如果 模型有多个输出). batch_size:整数.详细:详细 模式,0或1.
x: the input data, as a Numpy array (or list of Numpy arrays if the model has multiple outputs). batch_size: integer. verbose: verbosity mode, 0 or 1.
返回大量的预测数组.
model.predict(input_to_your_network)
这篇关于如何访问喀拉拉邦的班级概率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!