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

dwj*_*ton 5 machine-learning xor weka neural-network

我刚开始使用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. 选择 - >函数> multilayer_perceptron
  7. 单击顶部的"多层感知器"文本以打开设置.
  8. 将隐藏图层设置为"2".(如果选择gui为true,则表明这是我们想要的正确网络).点击确定.
  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. 如何传入一组进行分类?

小智 4

对于这两个示例,使用 0.5 的学习率可以完成 500 次迭代。学习率是它为新示例赋予的权重。显然这个问题很困难,并且很容易通过 2 个隐藏层达到局部最小值。如果您使用低学习率和高迭代次数,学习过程将更加保守,并且更有可能达到良好的最小值。