[英]How to set prediction threshold in Keras?
我用 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
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.