gpt4 book ai didi

python - 如何在Keras中设置预测阈值?

转载 作者:行者123 更新时间:2023-12-01 01:59:20 24 4
gpt4 key购买 nike

我使用 Keras 训练了一个模型来执行带有 0 和 1 标签的二元分类任务,并在一系列图像上对其进行了测试。其中一些图像非常相似,被预测为 1,所以我想知道是否有办法设置一些阈值或分数来在 Keras 中筛选出最有可能为 1 的图像?

最佳答案

如果您正在执行语义分割,请执行以下方法

执行

image = model.predict(your_input_image)
_,height,width,_ = image.shape()
image = image.reshape(height,width)
image[image >= threshold_percentage] = 255
image[image < threshold_percentage] = 0

如果是普通二进制

result = model.predict(your_input_image)
if result[0][1] > threshold_percentage:
#belongs to class 1
else:
#belongs to class 2

关于python - 如何在Keras中设置预测阈值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49842865/

24 4 0
文章推荐: javascript - jQuery 动态 div id 与 .each() 不起作用
文章推荐: jquery - 为什么我的 jquery 输入掩码不起作用?
文章推荐: javascript - 使用 jQuery 重新加载
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com