0

我目前的訓練網絡(CNN與Tensorflow實現),以超過3類進行分類,事情是,我最終喜歡得分:如何爲CNN的每個班級在0和1之間得分?

[ -20145.36, 150069, 578456.3 ]. 

我想有0和1之間的分數(某種概率)。

起初,我想過使用雙曲線函數,但後來我發現這個討論它甚至沒有提到:

https://www.quora.com/How-do-you-normalize-numeric-scores-to-a-0-1-range-for-comparing-different-machine-learning-techniques

你有什麼建議我做的有0和1之間的分數爲每個班級?

謝謝

+0

tf.nn.softmax()將變換網絡的輸出爲有效的概率分佈,即所有概率是0之間和1,它們總計爲1.請參閱此處以獲取TensorFlow文檔:https://www.tensorflow.org/api_docs/python/tf/nn/softmax以及此處的解釋:https://www.tensorflow.org/get_started/MNIST /初學者 – ml4294

回答

3

作爲最後一層,您總是使用softmax來獲得n級分類分數。所以,你有很多選項在tensorflow classification docs中提到。

最簡單的一種是使用tf.nn.softmax()

softmax = exp(logits)/reduce_sum(exp(logits), dim) 

實施例:

In [63]: ar = np.array([ -20145.36, 150069, 578456.3 ]) 

In [64]: scores = tf.nn.softmax(ar) 

In [65]: sess = tf.InteractiveSession() 

In [66]: scores.eval() 
Out[66]: array([ 0., 0., 1.]) 
相關問題