且构网

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

Keras多个二进制输出

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

对于多个类别分类问题,应使用categorical_crossentropy而不是binary_crossentropy.这样,当您的模型对输入进行分类时,它将给出所有200个类别之间的概率分散.接收到最高概率的类别将是该特定输入的输出.

For multiple category classification problems, you should use categorical_crossentropy rather than binary_crossentropy. With this, when your model classifies an input, it is going give a dispersion of probabilities between all 200 categories. The category that receives the highest probability will be the output for that particular input.

当您致电model.predict()时,您会看到此信息.例如,如果仅在一个输入上调用此函数并打印结果,则将看到200个百分比的结果(总计为1).希望这200个百分比中的一个比其他百分比高得多,这表明该模型认为对于特定的输入来说,这是正确的输出(类别)的可能性很大.

You can see this when you call model.predict(). If you were to call this function only on one input, for example, and print the results, you will see a result of 200 percentages (in total summing to 1). The hope is that one of those 200 percentages would be vastly higher than the others, which signals that the model thinks that there is a strong probability that this is the correct output (category) for this particular input.

此视频可能有助于阐明预测内容.打印预测开始于3:17左右,但是要获得完整的背景信息,您需要从头开始.

This video may help clarify the prediction piece. Printing out the predictions starts around 3:17, but to get the full context, you'll need to start from the beginning.