编程反向传播算法 [英] Programming the Back Propagation Algorithm

查看:71
本文介绍了编程反向传播算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我自己的网络中实现反向传播算法.我了解backprop agl的概念,但是我对数学并不坚强.我正在研究反向传播算法的前半部分,计算输出层(尚未担心隐藏层中的偏导数).

I'm trying to implement the backpropagation algoirthm into my own net. I understand the idea of the backprop agl, however, I'm not strong with math. I'm just working on the first half of the backprop alg, computing the output layer (not worrying about partial derivatives in the hidden layer(s) yet).

我在搜索时发现了以下代码,我正在寻找其中一部分的解释.

I found the following code while I was searching, and I'm looking for an explanation to one part of it.

int i = 0;
    for (Neuron n : outputLayer) {
        ArrayList<Connection> connections = n.getAllInConnections();
        for (Connection con : connections) {

            double output = n.getOutput();
            double ai = con.leftNeuron.getOutput();
            double desiredOutput = expectedOutput[i];
            double errorDerivative = (output * (1-output) *(desiredOutput - output));
            double deltaWeight = learningRate * errorDerivative * ai;
            double newWeight = con.getWeight() + deltaWeight;
            con.setDeltaWeight(deltaWeight);
            con.setWeight(newWeight);
        }
        i++;

那么,ai = con.leftNeuron.getOutput()将ai设置为上一层的输出吗?如果是这样,这到底是什么意思?从过去的层传递到特定神经元的权重之和?

So, ai = con.leftNeuron.getOutput() is setting ai to be the output from the previous layer? If so, what exactly does this mean? The sum of the summation of weights that was passed to the particular neuron from the past layer?

推荐答案

将AI设置为先前连接(无论连接到当前节点的任何节点)的leftNeuron的输出值.

AI is being set to the output value from the leftNeuron of the previous connection (whatever node that is connecting to the current one).

反向传播算法的工作方式是遍历ANN中的每一层以及其中的每个节点,然后求和该层中的所有权重(每个节点都有自己的权重),然后加上阈值,并计算此数字是否激活了下一个节点(如果数字> x->下一个节点被激活).

The way the back propagation algorithm works is by going through every layer in the ANN, and every node in it, then summing up all of the weights in that layer (each node has it's own weight), then adding in the threshold, and calculating if this number activates the next node (if number > x --> next node is activated).

您的代码正在做的事情是从输出层获取所有神经元,获取它们的所有连接,获取给定的神经元输出,从先前的神经元层获取权重,进行一些数学运算,以及根据我的理解,设置从上一层神经元到当前层神经元的连接权重.

What your code is doing is doing is getting all of the neurons from the output layer, getting all of their connections, getting the given neurons output, taking the weight from the previous layers left neuron, doing a bit of math, and setting the weight of the connection from the previous layer neuron to the current one from what I understand.

这里是了解ANN工作原理的重要链接, http://www.ai-junkie.com/ann/evolved/nnt1.html

Here's a great link for understanding the basics of how ANN work, http://www.ai-junkie.com/ann/evolved/nnt1.html

这篇关于编程反向传播算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆