CNN中无关图像的极限概率百分比 [英] Limiting probability percentage of irrelevant image in CNN

查看:73
本文介绍了CNN中无关图像的极限概率百分比的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用keras库训练具有五个类的cnn模型.使用model.predict函数,我得到了类的预测百分比.我的问题是对于不属于这些类别且完全不相关的图像,预测类别仍根据类别预测百分比.

I am training a cnn model with five classes using keras library. Using model.predict function i get prediction percentage of the classes. My problem is for a image which doesn't belong to these classes and completely irrelevant, the predict class still predicts the percentages according to the classes.

如何预防?我如何确定它无关紧要?

How do I prevent it? How do I identify it as irrelevant?

推荐答案

我假设您在最后一层使用softmax激活来生成每个类的概率.根据定义,softmax激活的输出总和必须总计为1.因此,对于神经网络来说,在当前设置下不可能说图像不属于您的任何类别.

I assume you are using a softmax activation on your last layer to generate the probabilities for each class. By definition, the sum of the outputs from the softmax activation must add up to 1. Therefore, it is impossible for the neural net to say that the image does not belong to any of your classes, with your current setup.

有两种潜在的解决方法:

There are two potential ways you could address this:

  1. 添加另一个表示其他"或未知"对象的类(因此,您有6个类).

  1. Add another class that represents "other" or "unknown" objects (so you have 6 classes).

将另一个输出添加到神经网络(或训练一个完全独立的神经网络),该输出将对图像是否属于5类之一进行二进制分类.这样,如果您的辅助输出显示该图像不在5类中,则可以忽略softmax输出.

Add another output to your neural net (or train a completely independent neural net) that does binary classification on whether or not the image is in one of the 5 classes. That way, if your secondary output says that the image is not in the 5 classes, you can ignore the softmax output.

在两种情况下,您都需要使用不属于5类的图像来扩充数据集.

In both cases, you will need to augment your dataset with images that do not fall in your 5 classes.

这篇关于CNN中无关图像的极限概率百分比的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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