2013-06-21 36 views
4

我剛剛開始使用Weka並遇到了第一步的麻煩。分步指南爲Weka中的異或情況訓練多層感知器?

我們已經得到了我們的訓練集:

 
@relation PerceptronXOR 
@attribute X1 numeric 
@attribute X2 numeric 
@attribute Output numeric 
@data 
1,1,-1 
-1,1,1 
1,-1,1 
-1,-1,-1 

第一步我想要做的只是訓練,然後進行分類使用Weka的GUI一套。 我到目前爲止所做的一切:

使用Weka 3.7.0。

  1. 啓動GUI。
  2. 資源管理器。
  3. 打開文件 - >選擇我的arff文件。
  4. 分類選項卡。
  5. 使用訓練集單選按鈕。
  6. 選擇 - >功能>多層感知器
  7. 單擊頂部的'多層感知器'文本打開設置。
  8. 將隱藏層設置爲'2'。 (如果gui選擇正確,則表明這是我們想要的正確網絡)。點擊確定。
  9. 點擊開始。

輸出:

 
=== Run information === 

Scheme:  weka.classifiers.functions.MultilayerPerceptron -L 0.3 -M 0.2 -N 500 -V 0 -S 0 -E 20 -H 2 -R 
Relation:  PerceptronXOR 
Instances: 4 
Attributes: 3 
       X1 
       X2 
       Output 
Test mode: evaluate on training data 

=== Classifier model (full training set) === 

Linear Node 0 
    Inputs Weights 
    Threshold 0.21069691964232443 
    Node 1 1.8781169869419072 
    Node 2 -1.8403146612166397 
Sigmoid Node 1 
    Inputs Weights 
    Threshold -3.7331156814378685 
    Attrib X1 3.6380519730323164 
    Attrib X2 -1.0420815868133226 
Sigmoid Node 2 
    Inputs Weights 
    Threshold -3.64785119182632 
    Attrib X1 3.603244645539393 
    Attrib X2 0.9535137571446323 
Class 
    Input 
    Node 0 


Time taken to build model: 0 seconds 

=== Evaluation on training set === 
=== Summary === 

Correlation coefficient     0.7047 
Mean absolute error      0.6073 
Root mean squared error     0.7468 
Relative absolute error     60.7288 % 
Root relative squared error    74.6842 % 
Total Number of Instances    4  

這似乎很奇怪,在0.3 500次迭代沒有得到它的錯誤,但5000 @ 0.1呢,所以讓我們一起去那。

現在使用的測試數據集:

 
@relation PerceptronXOR 
@attribute X1 numeric 
@attribute X2 numeric 
@attribute Output numeric 
@data 
1,1,-1 
-1,1,1 
1,-1,1 
-1,-1,-1 
0.5,0.5,-1 
-0.5,0.5,1 
0.5,-0.5,1 
-0.5,-0.5,-1 
  1. 單選按鈕,以 '提供的測試集'
  2. 選擇我的測試集ARFF。
  3. 點擊開始。
 
=== Run information === 

Scheme:  weka.classifiers.functions.MultilayerPerceptron -L 0.1 -M 0.2 -N 5000 -V 0 -S 0 -E 20 -H 2 -R 
Relation:  PerceptronXOR 
Instances: 4 
Attributes: 3 
       X1 
       X2 
       Output 
Test mode: user supplied test set: size unknown (reading incrementally) 

=== Classifier model (full training set) === 

Linear Node 0 
    Inputs Weights 
    Threshold -1.2208619057226187 
    Node 1 3.1172079341507497 
    Node 2 -3.212484459911485 
Sigmoid Node 1 
    Inputs Weights 
    Threshold 1.091378074639599 
    Attrib X1 1.8621040828953983 
    Attrib X2 1.800744048145267 
Sigmoid Node 2 
    Inputs Weights 
    Threshold -3.372580743113282 
    Attrib X1 2.9207154176666386 
    Attrib X2 2.576791630598144 
Class 
    Input 
    Node 0 


Time taken to build model: 0.04 seconds 

=== Evaluation on test set === 
=== Summary === 

Correlation coefficient     0.8296 
Mean absolute error      0.3006 
Root mean squared error     0.6344 
Relative absolute error     30.0592 % 
Root relative squared error    63.4377 % 
Total Number of Instances    8  

爲什麼無法將這些正確分類?

僅僅因爲它在訓練數據上很快達到當地最低標準,並且不知道那不適合所有情況?

問題。

  1. 爲什麼500 @ 0.3不起作用?對於這樣一個簡單的問題似乎很奇怪。
  2. 爲什麼它在測試集上失敗。
  3. 我該如何傳入一組來分類?
+1

1.如果學習率太高,它不會收斂。即使0.1有點大。 –

回答

4

使用0.5的學習率對兩個例子都做了500次迭代。 學習速度是它爲新例子提供的重量。 顯然這個問題很困難,並且很容易在2個隱藏層獲得局部極小值。如果您使用低迭代次數的學習率較低,學習過程將會更加保守,並且更有可能達到一個好的最小值。