2014-05-24 38 views
1

我正在嘗試使用Encog來處理this dataset。爲了做到這一點,我將輸出結果合併爲一個(似乎無法弄清楚如何使用多個預期輸出,即使我沒有成功嘗試手動訓練具有4個輸出神經元的NN),其值爲「disease1」, 「疾病2」,「無」和「兩者」。Encog查詢分類

從那裏開始,在CSV中使用分析師嚮導,自動過程用期望的輸出來訓練NN。來自文件的峯值:

"field:1","field:2","field:3","field:4","field:5","field:6","field:7","Output:field:7" 
40.5,yes,yes,yes,yes,no,both,both 
41.2,no,yes,yes,no,yes,second,second 

現在我的問題是:如何查詢它?我嘗試過分類,但據我瞭解,結果只給出值{0,1,2},所以有兩個類我不能區分(都是0)。

這個問題同樣適用於Wiki中提供的Iris示例。另外,Encog如何從輸出神經元值推斷到0/1/2結果?

編輯:我發現的解決方案是爲疾病1和疾病2使用單獨的網絡,但我真的很想知道是否有可能將這些組合成一個。

回答

2

您是對的,您需要將輸出列合併爲單個值。 Encog分析師將只分類到一個輸出列。該輸出列可以有許多不同的值。因此,將兩個輸出列標準化爲無,第一個,第二個都可以。如果直接使用底層神經網絡,則可以實際訓練兩個輸出,每個輸出做一個獨立的分類。但對於這個討論,我會假設我們正在與分析師打交道。

您是使用工作臺還是代碼查詢網絡?默認情況下,Encog分析師使用等邊編碼對神經網絡進行編碼。這導致許多輸出神經元等於n-1,其中n是類的數量。如果您在分析師嚮導中選擇n-1編碼,那麼BasicNetwork上的常規分類方法將起作用,因爲它僅用於n中的一個。

如果您想使用等邊查詢(在代碼中),則可以使用類似於以下的方法。我將它添加到Encog的下一個版本中。

/** 
* Used to classify a neural network that has been encoded using equilateral encoding. 
* This is the default for the Encog analyst. Equilateral encoding uses an output count 
* equal to the number of classes minus one. 
* @param input The input to the neural network. 
* @param high The high value of the activation range, usually 1. 
* @param low The low end of the normalization range, usually -1 or 0. 
* @return The class that the input belongs to. 
*/ 
public int classifyEquilateral(final MLData input,double high, double low) { 
    MLData result = this.compute(input); 
    Equilateral eq = new Equilateral(getOutputCount()+1,high,low); 
    return eq.decode(result.getData()); 
}