張量流文本分類:
https://www.tensorflow.org/tutorials/keras/text_classification
這個 text_classification 示例中只有兩個類,
Label 0 corresponds to neg
Label 1 corresponds to pos
但以下預測值既不是0也不是1:
examples = [
"The movie was great!",
"The movie was okay.",
"The movie was terrible..."
]
export_model.predict(examples)
array([[0.5921171 ],
[0.41369876],
[0.33293992]], dtype=float32)
"" 的結果The movie was great!是0.5921171,但這是什么意思?
positive是forvalue >= 0.5和negativefor 的意思value < 0.5嗎?
它應該將其預測為:
array([[1 ],
[1],
[0]], dtype=float32)
在該鏈接的末尾,有一個練習:
練習:關于 Stack Overflow 問題的多類分類
閾值 0.5 不適用于 Stack Overflow 問題的多類分類,因為本練習中共有 4 個標簽和類。
for i in range(len(raw_train_ds.class_names)):
print("Label: {}, Class Name: {}".format(i, raw_train_ds.class_names[i]))
Label: 0, Class Name: csharp
Label: 1, Class Name: java
Label: 2, Class Name: javascript
Label: 3, Class Name: python
我使用相同的示例陣列進行預測:
examples = [
"The movie was great!",
"The movie was okay.",
"The movie was terrible..."
]
export_model.predict(examples)
array([[0.52356344, 0.4763114 , 0.54468685, 0.4438951 ],
[0.52287084, 0.48242405, 0.5407451 , 0.4425373 ],
[0.5221944 , 0.4766879 , 0.5448719 , 0.4454918 ]], dtype=float32)
如何設定four multi-class classification堆疊溢位問題的閾值?
我認為這與閾值無關。
uj5u.com熱心網友回復:
你應該定義一個閾值,當你得到一個大于它的值時,它被認為是正的,否則它認為它是負的。在您獲得 [1,1,0] 的示例中,例如閾值 0.4 給出了正確的預測。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/432297.html
