在Weka中为XOR案例训练多层感知器的分步指南?

时间:2013-06-21 05:02:26

标签: machine-learning neural-network weka xor

我刚开始使用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. 打开文件 - >选择我的档案文件。
  4. 分类标签。
  5. 使用训练集单选按钮。
  6. Choose->功能> multilayer_perceptron
  7. 单击顶部的“多层感知器”文本以打开设置。
  8. 将隐藏图层设置为“2”。 (如果选择gui为true,则表明这是我们想要的正确网络)。点击确定。
  9. 点击开始。
  10. 输出:

    === 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. 点击开始。
    4. === 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 个答案:

答案 0 :(得分:4)

使用0.5的学习率可以完成两个示例的500次迭代。 学习率是新例子的重量。 显然问题很难,并且很容易通过2个隐藏层进入局部最小值。如果您使用具有较高迭代次数的低学习率,则学习过程将更加保守,并且更有可能达到最佳。