简体   繁体   English

具有6种功能的人工神经网络训练

[英]Artificial Neural Network training with 6 features

I want to ask the following question : I am trying to train an artificial neural network with backpropagation. 我想问以下问题:我正在尝试使用反向传播训练人工神经网络。 I have a feedforward neural network with 6 input layers 7 hidden and 1 output. 我有一个前馈神经网络,其中隐藏了6个输入层和1个输出。 I will give to this neural network a feature vector made up of 6 features and train it, my learning rate is 0.7 and my momentum is 0.9. 我将给这个神经网络一个由6个特征组成的特征向量并对其进行训练,我的学习率是0.7,动量是0.9。 I want to classify based on my 6 features in 2 classes. 我想根据我的6个功能在2个类别中进行分类。 The problem is that the overall error of this network doesn't change... I have tried different values for the learning rates and momentum but the problem was still the same... I don't understand why it is dooing this. 问题是该网络的总体误差不会改变...我尝试了不同的学习率和动量值,但问题仍然相同...我不明白为什么这样做会失败。 I have tried the same code(I mean the main classes) when trying to learn a ann to learn to do the xor problem and it worked there perfectly. 当我尝试学习ann来学习xor问题时,我尝试了相同的代码(我的意思是主类),并且在那儿工作得很好。 Does anyone have any idea why this is happening? 有谁知道为什么会这样吗? Thank you for your time :) 感谢您的时间 :)

FeedforwardNetwork network = new FeedforwardNetwork();
Train train;

 network.AddLayer(new FeedforwardLayer(6));
        network.AddLayer(new FeedforwardLayer(7));
        network.AddLayer(new FeedforwardLayer(1));

        train = new Backpropagation(network, Input_vector, Ideal_vector, 0.7, 0.8);

        int epoch = 1;
        textBox7.Text = " It has begun\r\n";
        do
        {
            train.Iteration();
            textBox7.Text += "\r\n Epoch " + epoch + " Error " + train.Error + " \r\n ";

            epoch++;
        }
        while ((epoch < 500) && (train.Error > 0.001));

        network = train.Network;

        textBox7.Text += "Neural Network Results";

        for (int i = 0; i < Ideal_vector.Length; i++)
        {
            double[] actual = network.ComputeOutputs(Input_vector[i]);

            textBox7.Text += "\r\n" + Input_vector[i][0] + "," + Input_vector[i][1] +     "," +
                Input_vector[i][2] + "," + Input_vector[i][3] + Input_vector[i][4] +
                Input_vector[i][5] + " actual= " +
                actual[0] + ", ideal " + Ideal_vector[i][0] + " \r\n";
        }

Are you using batch learning or online learning? 您正在使用批处理学习还是在线学习? If the answer is batch, then maybe your learning rate is too high. 如果答案是批量的,那么您的学习率可能会太高。 You can try scaling it dividing for the number of training patterns. 您可以尝试按比例缩放除以训练模式的数量。 As @Marcom said, if you have too few neurons your network has too low capacity, that's a bit rough to explain but basically you aren't using the non-linear region of the neurons and your network is biased. 正如@Marcom所说,如果您的神经元太少,您的网络容量就会太低,这有点难以解释,但是基本上您不是在使用神经元的非线性区域,而且您的网络是有偏差的。

Check here for a better explanation. 检查这里以获得更好的解释。

Try with a huge number of neurons first, then you can decrease the number as long as the error keeps going down. 首先尝试使用大量的神经元,然后只要错误不断减少,就可以减少神经元的数目。

Try experimenting with adding an additional hidden layer and also try increasing the number of hidden nodes. 尝试添加额外的隐藏层,并尝试增加隐藏节点的数量。 I can't give you a technical explanation off my head but if you have too few nodes the ann might not be able to converge. 我无法为您提供技术上的解释,但是如果节点太少,则ann可能无法收敛。

Your main function is fine. 您的主要功能很好。 However either your training vectors or your backpropagation code is not (assuming your network is big enough to learn this). 但是,您的训练向量或反向传播代码都不是(假设您的网络足够大,可以学习此知识)。 So this is going to be a bunch of question instead of an answer, but you may get the right idea: 因此,这将是一堆问题而不是答案,但是您可能会得到正确的想法:

  • How many samples does your training vector include? 您的训练向量包含多少样本?
  • Are those samples roughly classified half/half or is there a bias? 这些样本是否大致分为一半/一半?是否有偏差?
  • Are there identical training samples that are classified ambiguously? 是否有相同的训练样本被模糊地分类?
  • How is the error calculated? 误差如何计算? Abs/Sqr average? Abs / Sqr平均吗?
  • Do you randomize the initial network weights? 您是否将初始网络权重随机化?
  • What is the initial error before training? 训练的最初错误是什么?
  • Does the error change in the first iteration? 错误在第一次迭代中会改变吗?
  • Can you post the code on pastebin? 您可以将代码发布在pastebin上吗?

A loss function not evolving at the start in an MLP is usually because the network can't infer any rules to fit your training data (the grad of your backprop can't find any meaningful local minima) . MLP最初没有发展的损失函数通常是因为网络无法推断出适合您的训练数据的任何规则(反向支撑的等级找不到任何有意义的局部最小值)。 This can be caused by a lack of data for the problem you try to resolve, or a restricted architecture. 这可能是由于您要解决的问题的数据不足或体系结构受限制所致。

Increasing your number of layers and/or the size of them should change that. 增加层数和/或它们的大小应该可以改变这种情况。 Although you will be prone to overfitting if your architecture is too complex. 尽管如果您的体系结构过于复杂,则很容易过度拟合。 You will have to find a balance fitting to your problem. 您将必须找到适合您问题的平衡点。

And don't hesitate to start with a low learning rate at first, setting it too high will cause your gradient to "bounce" and not converge. 而且不要一开始就从低学习率开始,设置得太高会导致您的梯度“反弹”并且不会收敛。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM