且构网

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

如何使用 Keras 中的训练模型预测输入图像?

更新时间:2023-12-01 21:44:28

keras predict_classes (docs) 输出类预测的 numpy 数组.在您的模型案例中,您的最后一个(softmax)层的最高激活神经元的索引.[[0]] 意味着你的模型预测你的测试数据是 0 类.(通常你会传递多张图像,结果看起来像 [[0], [1], [1], [0]] )

keras predict_classes (docs) outputs A numpy array of class predictions. Which in your model case, the index of neuron of highest activation from your last(softmax) layer. [[0]] means that your model predicted that your test data is class 0. (usually you will be passing multiple image, and the result will look like [[0], [1], [1], [0]] )

您必须将实际标签(例如 'cancer'、'notcancer')转换为二进制编码(0 代表 'cancer'、1代码> 表示非癌症")进行二元分类.然后,您将 [[0]] 的序列输出解释为具有类标签 'cancer'

You must convert your actual label (e.g. 'cancer', 'not cancer') into binary encoding (0 for 'cancer', 1 for 'not cancer') for binary classification. Then you will interpret your sequence output of [[0]] as having class label 'cancer'