gpt4 book ai didi

java - 反向传播算法编程

转载 作者:行者123 更新时间:2023-11-30 09:37:50 24 4
gpt4 key购买 nike

我正在尝试将反向传播算法实现到我自己的网络中。我理解反向传播 agl 的想法,但是,我的数学能力并不强。我只是在研究反向传播算法的前半部分,计算输出层(还不担心隐藏层中的偏导数)。

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

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 设置为上一层的输出?如果是这样,这到底意味着什么?从上一层传递到特定神经元的权重总和?

最佳答案

AI 被设置为前一个连接的 leftNeuron 的输出值(无论连接到当前节点的节点)。

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

你的代码正在做的是从输出层获取所有神经元,获取它们的所有连接,获取给定的神经元输出,从前一层左神经元中获取权重,做一些数学计算,然后根据我的理解,设置从前一层神经元到当前层神经元的连接权重。

这里有一个很好的链接,可以帮助您了解 ANN 工作原理的基础知识,http://www.ai-junkie.com/ann/evolved/nnt1.html

关于java - 反向传播算法编程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30580316/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com