網上抄的指標代碼,應該沒問題,但是為啥運行中顯示的這倆指標都是一樣的?還定義了一個f1,也和他們一樣?有大佬知道為什么嗎?
def check_units(y_true, y_pred):
if y_pred.shape[1] != 1:
y_pred = y_pred[:,1:2]
y_true = y_true[:,1:2]
return y_true, y_pred
def precision(y_true, y_pred):
y_true, y_pred = check_units(y_true, y_pred)
true_positives = K.sum(K.round(K.clip(y_true * y_pred, 0, 1)))
predicted_positives = K.sum(K.round(K.clip(y_pred, 0, 1)))
precision = true_positives / (predicted_positives + K.epsilon())
return precision
def recall(y_true, y_pred):
y_true, y_pred = check_units(y_true, y_pred)
true_positives = K.sum(K.round(K.clip(y_true * y_pred, 0, 1)))
possible_positives = K.sum(K.round(K.clip(y_true, 0, 1)))
recall = true_positives / (possible_positives + K.epsilon())
return recall
下面是運行部分截圖
12/846 [..............................] - ETA: 6:37 - loss: 5.2509 - accuracy: 0.1624 - precision: 0.1624 - recall: 0.1624 - f1: 0.1624
13/846 [..............................] - ETA: 6:23 - loss: 5.2181 - accuracy: 0.1641 - precision: 0.1641 - recall: 0.1641 - f1: 0.1641
14/846 [..............................] - ETA: 6:16 - loss: 5.1733 - accuracy: 0.1666 - precision: 0.1666 - recall: 0.1666 - f1: 0.1666
15/846 [..............................] - ETA: 6:05 - loss: 5.1398 - accuracy: 0.1686 - precision: 0.1686 - recall: 0.1686 - f1: 0.1686
16/846 [..............................] - ETA: 5:55 - loss: 5.1052 - accuracy: 0.1703 - precision: 0.1703 - recall: 0.1703 - f1: 0.1703
17/846 [..............................] - ETA: 5:46 - loss: 5.0709 - accuracy: 0.1722 - precision: 0.1722 - recall: 0.1722 - f1: 0.1722
uj5u.com熱心網友回復:
你的precision和recall方法 內部一模一樣,出來的結果肯定是一樣的啊。。uj5u.com熱心網友回復:
不一樣啊,兩個的possible_positives不一樣轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/46676.html
標籤:機器視覺
下一篇:LG電腦顯示幕如何校準顏色?
