当我整理代码时,我相信两个反向传播方法backpropError()和updateWeights()存在问题。我不确定发生了什么,但是某些变量可能已被其他变量替代。请使用下面的主要方法查看我的预期输出。
我尝试恢复到先前的代码,然后再次整理。每次运行程序时,我似乎仍然继续遇到输出层神经元输出为0或1的问题。值得庆幸的是,我确实在某个时间点有工作代码,但是我相信由于人为错误,我弄乱了代码。我搜索了几个小时,逐行告诉自己代码是做什么的(鸭子调试)。虽然,我还没有那么成功。我是机器学习的新手,所以我可能对这个主题不了解。因此,如果我不停地告诉自己某些事情还不错,那么执行这种鸭子调试方法可能就没用了。
public void train(double[] input, double[] target, double eta) {
if (input.length != nodes[0].getNeurons().length
|| target.length != nodes[nodes.length - 1].getNeurons().length)
return;
calculate(input);
backpropError(target);
updateWeights(eta);
}
public void backpropError(double[] target) {
for (int neuron = 0; neuron < nodes[nodes.length - 1].getNeurons().length; neuron++) {
nodes[nodes.length - 1].getNeurons()[neuron]
.setError((nodes[nodes.length - 1].getNeurons()[neuron].getOutput() - target[neuron])
* nodes[nodes.length - 1].getNeurons()[neuron].getDerivative());
}
for (int node = nodes.length - 2; node > 0; node--) {
for (int neuron = 0; neuron < nodes[node].getNeurons().length; neuron++) {
double sum = 0;
for (int nextNeuron = 0; nextNeuron < nodes[node + 1].getNeurons().length; nextNeuron++) {
sum += nodes[node + 1].getNeurons()[nextNeuron].getWeight()
* nodes[node + 1].getNeurons()[nextNeuron].getError();
}
nodes[node].getNeurons()[neuron].setError(sum * nodes[node].getNeurons()[neuron].getDerivative());
}
}
}
public void updateWeights(double eta) {
for (int node = 1; node < nodes.length; node++) {
for (int neuron = 0; neuron < nodes[node].getNeurons().length; neuron++) {
for (int prevNeuron = 0; prevNeuron < nodes[node - 1].getNeurons().length; prevNeuron++) {
double error = nodes[node].getNeurons()[neuron].getError();
double output = nodes[node - 1].getNeurons()[prevNeuron].getOutput();
double delta = -eta * output * error;
nodes[node].getNeurons()[neuron].setWeight(nodes[node].getNeurons()[neuron].getWeight() + delta);
}
double delta = -eta * nodes[node].getNeurons()[neuron].getError();
double bias = nodes[node].getNeurons()[neuron].getBias() + delta;
nodes[node].getNeurons()[neuron].setBias(bias);
}
}
}
预期结果(应该在这些数字附近,实际上是除1或0以外的其他值)
0 to 1 for (1, 1) is [0.9910935509899885]
0 to 1 for (1, 2) is [0.9871773794454903]
0 to 1 for (1, 3) is [0.9838927795406156]
0 to 1 for (1, 4) is [0.9828189052953983]
0 to 1 for (1, 5) is [0.9815991423542645]
0 to 1 for (1, 6) is [0.9803403986584942]
0 to 1 for (1, 7) is [0.979499016873949]
0 to 1 for (1, 8) is [0.9794319620385957]
0 to 1 for (1, 9) is [0.9800242475225174]
0 to 1 for (1, 10) is [0.9809058626958285]
0 to 1 for (1, 11) is [0.9817904137442123]
0 to 1 for (1, 12) is [0.9825518144017069]
0 to 1 for (1, 13) is [0.9831637133385046]
0 to 1 for (1, 14) is [0.9836404769001028]
0 to 1 for (2, 1) is [0.9862969293604603]
0 to 1 for (2, 2) is [0.9549009660191852]
0 to 1 for (2, 3) is [0.11050115482127897]
0 to 1 for (2, 4) is [0.0626704670893195]
0 to 1 for (2, 5) is [0.055663128315963324]
0 to 1 for (2, 6) is [0.06640237815840831]
0 to 1 for (2, 7) is [0.10274974744717426]
0 to 1 for (2, 8) is [0.18672041155749838]
0 to 1 for (2, 9) is [0.3430998911897474]
0 to 1 for (2, 10) is [0.5525757350811092]
0 to 1 for (2, 11) is [0.7391256474088206]
0 to 1 for (2, 12) is [0.857042325903226]
0 to 1 for (2, 13) is [0.9184488099343571]
0 to 1 for (2, 14) is [0.9484728504347214]
0 to 1 for (3, 1) is [0.9887628894792877]
0 to 1 for (3, 2) is [0.9846981057752352]
0 to 1 for (3, 3) is [0.022584775002207395]
0 to 1 for (3, 4) is [0.002170995253960961]
0 to 1 for (3, 5) is [0.0013124123151204412]
0 to 1 for (3, 6) is [0.0010469553419766315]
0 to 1 for (3, 7) is [9.837147147492913E-4]
0 to 1 for (3, 8) is [0.0010474499199396902]
0 to 1 for (3, 9) is [0.0012383813313086292]
0 to 1 for (3, 10) is [0.0016167114538286468]
0 to 1 for (3, 11) is [0.002344176509696699]
0 to 1 for (3, 12) is [0.0038217813761690566]
0 to 1 for (3, 13) is [0.0070918853552621895]
0 to 1 for (3, 14) is [0.015015861087589701]
0 to 1 for (4, 1) is [0.9879713128525816]
0 to 1 for (4, 2) is [0.9867875404881303]
0 to 1 for (4, 3) is [0.9692130314107957]
0 to 1 for (4, 4) is [0.010435719778705116]
0 to 1 for (4, 5) is [8.479877085185381E-4]
0 to 1 for (4, 6) is [5.785743076028941E-4]
0 to 1 for (4, 7) is [5.125051554109539E-4]
0 to 1 for (4, 8) is [4.864223217883289E-4]
0 to 1 for (4, 9) is [4.7831957307317756E-4]
0 to 1 for (4, 10) is [4.814094865592372E-4]
0 to 1 for (4, 11) is [4.935711951870427E-4]
0 to 1 for (4, 12) is [5.151951321750555E-4]
0 to 1 for (4, 13) is [5.486282726224604E-4]
0 to 1 for (4, 14) is [5.984615833851663E-4]
0 to 1 for (5, 1) is [0.9894097556012034]
0 to 1 for (5, 2) is [0.9324704752519336]
0 to 1 for (5, 3) is [0.9834719183593317]
0 to 1 for (5, 4) is [0.6971667759057901]
0 to 1 for (5, 5) is [0.04027962824677335]
0 to 1 for (5, 6) is [7.691150864100421E-4]
0 to 1 for (5, 7) is [4.821067772585261E-4]
0 to 1 for (5, 8) is [4.489605523967905E-4]
0 to 1 for (5, 9) is [4.3772104110867437E-4]
0 to 1 for (5, 10) is [4.316087458406918E-4]
0 to 1 for (5, 11) is [4.2774669110435734E-4]
0 to 1 for (5, 12) is [4.252602170490725E-4]
0 to 1 for (5, 13) is [4.239632294492619E-4]
0 to 1 for (5, 14) is [4.2402806595500194E-4]
0 to 1 for (6, 1) is [0.9901940478365552]
0 to 1 for (6, 2) is [0.5437564428713505]
0 to 1 for (6, 3) is [0.959381938750295]
0 to 1 for (6, 4) is [0.9647857578047029]
0 to 1 for (6, 5) is [0.5360297761331198]
0 to 1 for (6, 6) is [0.18415875419143782]
0 to 1 for (6, 7) is [0.0011695129645863825]
0 to 1 for (6, 8) is [4.780733046891528E-4]
0 to 1 for (6, 9) is [4.3982498725370935E-4]
0 to 1 for (6, 10) is [4.333427709396414E-4]
0 to 1 for (6, 11) is [4.2995799933939375E-4]
0 to 1 for (6, 12) is [4.269577050228604E-4]
0 to 1 for (6, 13) is [4.238798570000804E-4]
0 to 1 for (6, 14) is [4.2062605777177386E-4]
0 to 1 for (7, 1) is [0.9903353230958046]
0 to 1 for (7, 2) is [0.35043968141301496]
0 to 1 for (7, 3) is [0.1833408977020958]
0 to 1 for (7, 4) is [0.969785111124215]
0 to 1 for (7, 5) is [0.7642636401486528]
0 to 1 for (7, 6) is [0.5204055905016373]
0 to 1 for (7, 7) is [0.3637215499949285]
0 to 1 for (7, 8) is [0.0034749277209424902]
0 to 1 for (7, 9) is [5.194607003565761E-4]
0 to 1 for (7, 10) is [4.4230955819922913E-4]
0 to 1 for (7, 11) is [4.351826292320367E-4]
0 to 1 for (7, 12) is [4.331717718460902E-4]
0 to 1 for (7, 13) is [4.313813412158807E-4]
0 to 1 for (7, 14) is [4.2929802609048486E-4]
0 to 1 for (8, 1) is [0.9901866253428777]
0 to 1 for (8, 2) is [0.4836301425377847]
0 to 1 for (8, 3) is [0.018636385216974524]
0 to 1 for (8, 4) is [0.8411527254336554]
0 to 1 for (8, 5) is [0.9590131257757649]
0 to 1 for (8, 6) is [0.560975541337476]
0 to 1 for (8, 7) is [0.5202011938297898]
0 to 1 for (8, 8) is [0.4550128573555017]
0 to 1 for (8, 9) is [0.02385028802682653]
0 to 1 for (8, 10) is [6.41671244663098E-4]
0 to 1 for (8, 11) is [4.506605397740652E-4]
0 to 1 for (8, 12) is [4.3748396283955213E-4]
0 to 1 for (8, 13) is [4.357369209836286E-4]
0 to 1 for (8, 14) is [4.347180579827464E-4]
0 to 1 for (9, 1) is [0.9899390765977687]
0 to 1 for (9, 2) is [0.8399370878183416]
0 to 1 for (9, 3) is [0.011129476335252401]
0 to 1 for (9, 4) is [0.02806677171382546]
0 to 1 for (9, 5) is [0.9582212603105172]
0 to 1 for (9, 6) is [0.8346560067039187]
0 to 1 for (9, 7) is [0.5291576093740291]
0 to 1 for (9, 8) is [0.5212906726893675]
0 to 1 for (9, 9) is [0.4934193747652197]
0 to 1 for (9, 10) is [0.1519775493397618]
0 to 1 for (9, 11) is [0.0010360345440814992]
0 to 1 for (9, 12) is [4.69011552278298E-4]
0 to 1 for (9, 13) is [4.399337918989782E-4]
0 to 1 for (9, 14) is [4.3733611346780473E-4]
0 to 1 for (10, 1) is [0.9896951852794307]
0 to 1 for (10, 2) is [0.9610686950595871]
0 to 1 for (10, 3) is [0.010013740573165238]
0 to 1 for (10, 4) is [0.006871740432363109]
0 to 1 for (10, 5) is [0.6318311447354207]
0 to 1 for (10, 6) is [0.9610571704963261]
0 to 1 for (10, 7) is [0.5840812264437744]
0 to 1 for (10, 8) is [0.5240141740137221]
0 to 1 for (10, 9) is [0.5220379233704295]
0 to 1 for (10, 10) is [0.5098689863166235]
0 to 1 for (10, 11) is [0.3443839939409853]
0 to 1 for (10, 12) is [0.002922373707535057]
0 to 1 for (10, 13) is [5.118254079388835E-4]
0 to 1 for (10, 14) is [4.436158059964742E-4]
0 to 1 for (11, 1) is [0.9895032468019129]
0 to 1 for (11, 2) is [0.9801502617229543]
0 to 1 for (11, 3) is [0.011475840240417949]
0 to 1 for (11, 4) is [0.005595602667548773]
0 to 1 for (11, 5) is [0.013716134157716631]
0 to 1 for (11, 6) is [0.949108043127969]
0 to 1 for (11, 7) is [0.89927269900398]
0 to 1 for (11, 8) is [0.5321033036732302]
0 to 1 for (11, 9) is [0.5230544639770932]
0 to 1 for (11, 10) is [0.5224358077629269]
0 to 1 for (11, 11) is [0.5170716230969831]
0 to 1 for (11, 12) is [0.44705842387761996]
0 to 1 for (11, 13) is [0.018799683752460487]
0 to 1 for (11, 14) is [6.222508089649084E-4]
0 to 1 for (12, 1) is [0.9893736928790977]
0 to 1 for (12, 2) is [0.9847786388427392]
0 to 1 for (12, 3) is [0.01896283977730271]
0 to 1 for (12, 4) is [0.005407602105348822]
0 to 1 for (12, 5) is [0.005449115032948711]
0 to 1 for (12, 6) is [0.3730139176451379]
0 to 1 for (12, 7) is [0.9630156824209855]
0 to 1 for (12, 8) is [0.6313522740222185]
0 to 1 for (12, 9) is [0.5243698631777768]
0 to 1 for (12, 10) is [0.5228576507021224]
0 to 1 for (12, 11) is [0.5226302263851187]
0 to 1 for (12, 12) is [0.5202557871829716]
0 to 1 for (12, 13) is [0.4901248679218462]
0 to 1 for (12, 14) is [0.1304316526169098]
0 to 1 for (13, 1) is [0.9892966744432541]
0 to 1 for (13, 2) is [0.9865316742464783]
0 to 1 for (13, 3) is [0.06564852666000326]
0 to 1 for (13, 4) is [0.0054721184936793585]
0 to 1 for (13, 5) is [0.004867783115298201]
0 to 1 for (13, 6) is [0.009583222885946732]
0 to 1 for (13, 7) is [0.9365627197723527]
0 to 1 for (13, 8) is [0.9352945261638724]
0 to 1 for (13, 9) is [0.5387289780836262]
0 to 1 for (13, 10) is [0.5230760846347143]
0 to 1 for (13, 11) is [0.522813162059462]
0 to 1 for (13, 12) is [0.5227214724637188]
0 to 1 for (13, 13) is [0.5216684507175157]
0 to 1 for (13, 14) is [0.508457205676473]
0 to 1 for (14, 1) is [0.9892565340396582]
0 to 1 for (14, 2) is [0.9874263277129101]
0 to 1 for (14, 3) is [0.4663114754657409]
0 to 1 for (14, 4) is [0.005744763861636081]
0 to 1 for (14, 5) is [0.004802455574059894]
0 to 1 for (14, 6) is [0.005074088662961573]
0 to 1 for (14, 7) is [0.1722728810501328]
0 to 1 for (14, 8) is [0.9635681203522549]
0 to 1 for (14, 9) is [0.7087565262644769]
0 to 1 for (14, 10) is [0.5253841754190232]
0 to 1 for (14, 11) is [0.5228492547806377]
0 to 1 for (14, 12) is [0.5228020161647765]
0 to 1 for (14, 13) is [0.5227633407783717]
0 to 1 for (14, 14) is [0.5222959260173418]
但是实际结果始终为0(舍入误差)或1
0 to 1 for (1, 1) is [9.189855591893272E-5]
0 to 1 for (1, 2) is [9.027276923346102E-5]
0 to 1 for (1, 3) is [8.891150466152272E-5]
0 to 1 for (1, 4) is [8.78660505133688E-5]
0 to 1 for (1, 5) is [8.71098697393772E-5]
0 to 1 for (1, 6) is [8.65842971467477E-5]
0 to 1 for (1, 7) is [8.622826560353094E-5]
0 to 1 for (1, 8) is [8.599093057198876E-5]
0 to 1 for (1, 9) is [8.58342543422109E-5]
0 to 1 for (1, 10) is [8.57314058901042E-5]
0 to 1 for (1, 11) is [8.566409414131898E-5]
0 to 1 for (1, 12) is [8.56200986607846E-5]
0 to 1 for (1, 13) is [8.559135101906912E-5]
0 to 1 for (1, 14) is [8.557256002536103E-5]
0 to 1 for (2, 1) is [9.027276923346102E-5]
0 to 1 for (2, 2) is [8.891150466152272E-5]
0 to 1 for (2, 3) is [8.78660505133688E-5]
0 to 1 for (2, 4) is [8.71098697393772E-5]
0 to 1 for (2, 5) is [8.65842971467477E-5]
0 to 1 for (2, 6) is [8.622826560353094E-5]
0 to 1 for (2, 7) is [8.599093057198876E-5]
0 to 1 for (2, 8) is [8.58342543422109E-5]
0 to 1 for (2, 9) is [8.57314058901042E-5]
0 to 1 for (2, 10) is [8.566409414131898E-5]
0 to 1 for (2, 11) is [8.56200986607846E-5]
0 to 1 for (2, 12) is [8.559135101906912E-5]
0 to 1 for (2, 13) is [8.557256002536103E-5]
0 to 1 for (2, 14) is [8.55602682883699E-5]
0 to 1 for (3, 1) is [8.891150466152272E-5]
0 to 1 for (3, 2) is [8.78660505133688E-5]
0 to 1 for (3, 3) is [8.71098697393772E-5]
0 to 1 for (3, 4) is [8.65842971467477E-5]
0 to 1 for (3, 5) is [8.622826560353094E-5]
0 to 1 for (3, 6) is [8.599093057198876E-5]
0 to 1 for (3, 7) is [8.58342543422109E-5]
0 to 1 for (3, 8) is [8.57314058901042E-5]
0 to 1 for (3, 9) is [8.566409414131898E-5]
0 to 1 for (3, 10) is [8.56200986607846E-5]
0 to 1 for (3, 11) is [8.559135101906912E-5]
0 to 1 for (3, 12) is [8.557256002536103E-5]
0 to 1 for (3, 13) is [8.55602682883699E-5]
0 to 1 for (3, 14) is [8.555222039216433E-5]
0 to 1 for (4, 1) is [8.78660505133688E-5]
0 to 1 for (4, 2) is [8.71098697393772E-5]
0 to 1 for (4, 3) is [8.65842971467477E-5]
0 to 1 for (4, 4) is [8.622826560353094E-5]
0 to 1 for (4, 5) is [8.599093057198876E-5]
0 to 1 for (4, 6) is [8.58342543422109E-5]
0 to 1 for (4, 7) is [8.57314058901042E-5]
0 to 1 for (4, 8) is [8.566409414131898E-5]
0 to 1 for (4, 9) is [8.56200986607846E-5]
0 to 1 for (4, 10) is [8.559135101906912E-5]
0 to 1 for (4, 11) is [8.557256002536103E-5]
0 to 1 for (4, 12) is [8.55602682883699E-5]
0 to 1 for (4, 13) is [8.555222039216433E-5]
0 to 1 for (4, 14) is [8.554694566332781E-5]
0 to 1 for (5, 1) is [8.71098697393772E-5]
0 to 1 for (5, 2) is [8.65842971467477E-5]
0 to 1 for (5, 3) is [8.622826560353094E-5]
0 to 1 for (5, 4) is [8.599093057198876E-5]
0 to 1 for (5, 5) is [8.58342543422109E-5]
0 to 1 for (5, 6) is [8.57314058901042E-5]
0 to 1 for (5, 7) is [8.566409414131898E-5]
0 to 1 for (5, 8) is [8.56200986607846E-5]
0 to 1 for (5, 9) is [8.559135101906912E-5]
0 to 1 for (5, 10) is [8.557256002536103E-5]
0 to 1 for (5, 11) is [8.55602682883699E-5]
0 to 1 for (5, 12) is [8.555222039216433E-5]
0 to 1 for (5, 13) is [8.554694566332781E-5]
0 to 1 for (5, 14) is [8.554348483303577E-5]
0 to 1 for (6, 1) is [8.65842971467477E-5]
0 to 1 for (6, 2) is [8.622826560353094E-5]
0 to 1 for (6, 3) is [8.599093057198876E-5]
0 to 1 for (6, 4) is [8.58342543422109E-5]
0 to 1 for (6, 5) is [8.57314058901042E-5]
0 to 1 for (6, 6) is [8.566409414131898E-5]
0 to 1 for (6, 7) is [8.56200986607846E-5]
0 to 1 for (6, 8) is [8.559135101906912E-5]
0 to 1 for (6, 9) is [8.557256002536103E-5]
0 to 1 for (6, 10) is [8.55602682883699E-5]
0 to 1 for (6, 11) is [8.555222039216433E-5]
0 to 1 for (6, 12) is [8.554694566332781E-5]
0 to 1 for (6, 13) is [8.554348483303577E-5]
0 to 1 for (6, 14) is [8.554121173362674E-5]
0 to 1 for (7, 1) is [8.622826560353094E-5]
0 to 1 for (7, 2) is [8.599093057198876E-5]
0 to 1 for (7, 3) is [8.58342543422109E-5]
0 to 1 for (7, 4) is [8.57314058901042E-5]
0 to 1 for (7, 5) is [8.566409414131898E-5]
0 to 1 for (7, 6) is [8.56200986607846E-5]
0 to 1 for (7, 7) is [8.559135101906912E-5]
0 to 1 for (7, 8) is [8.557256002536103E-5]
0 to 1 for (7, 9) is [8.55602682883699E-5]
0 to 1 for (7, 10) is [8.555222039216433E-5]
0 to 1 for (7, 11) is [8.554694566332781E-5]
0 to 1 for (7, 12) is [8.554348483303577E-5]
0 to 1 for (7, 13) is [8.554121173362674E-5]
0 to 1 for (7, 14) is [8.553971722241507E-5]
0 to 1 for (8, 1) is [8.599093057198876E-5]
0 to 1 for (8, 2) is [8.58342543422109E-5]
0 to 1 for (8, 3) is [8.57314058901042E-5]
0 to 1 for (8, 4) is [8.566409414131898E-5]
0 to 1 for (8, 5) is [8.56200986607846E-5]
0 to 1 for (8, 6) is [8.559135101906912E-5]
0 to 1 for (8, 7) is [8.557256002536103E-5]
0 to 1 for (8, 8) is [8.55602682883699E-5]
0 to 1 for (8, 9) is [8.555222039216433E-5]
0 to 1 for (8, 10) is [8.554694566332781E-5]
0 to 1 for (8, 11) is [8.554348483303577E-5]
0 to 1 for (8, 12) is [8.554121173362674E-5]
0 to 1 for (8, 13) is [8.553971722241507E-5]
0 to 1 for (8, 14) is [8.553873366206768E-5]
0 to 1 for (9, 1) is [8.58342543422109E-5]
0 to 1 for (9, 2) is [8.57314058901042E-5]
0 to 1 for (9, 3) is [8.566409414131898E-5]
0 to 1 for (9, 4) is [8.56200986607846E-5]
0 to 1 for (9, 5) is [8.559135101906912E-5]
0 to 1 for (9, 6) is [8.557256002536103E-5]
0 to 1 for (9, 7) is [8.55602682883699E-5]
0 to 1 for (9, 8) is [8.555222039216433E-5]
0 to 1 for (9, 9) is [8.554694566332781E-5]
0 to 1 for (9, 10) is [8.554348483303577E-5]
0 to 1 for (9, 11) is [8.554121173362674E-5]
0 to 1 for (9, 12) is [8.553971722241507E-5]
0 to 1 for (9, 13) is [8.553873366206768E-5]
0 to 1 for (9, 14) is [8.553808577512288E-5]
0 to 1 for (10, 1) is [8.57314058901042E-5]
0 to 1 for (10, 2) is [8.566409414131898E-5]
0 to 1 for (10, 3) is [8.56200986607846E-5]
0 to 1 for (10, 4) is [8.559135101906912E-5]
0 to 1 for (10, 5) is [8.557256002536103E-5]
0 to 1 for (10, 6) is [8.55602682883699E-5]
0 to 1 for (10, 7) is [8.555222039216433E-5]
0 to 1 for (10, 8) is [8.554694566332781E-5]
0 to 1 for (10, 9) is [8.554348483303577E-5]
0 to 1 for (10, 10) is [8.554121173362674E-5]
0 to 1 for (10, 11) is [8.553971722241507E-5]
0 to 1 for (10, 12) is [8.553873366206768E-5]
0 to 1 for (10, 13) is [8.553808577512288E-5]
0 to 1 for (10, 14) is [8.553765863742363E-5]
0 to 1 for (11, 1) is [8.566409414131898E-5]
0 to 1 for (11, 2) is [8.56200986607846E-5]
0 to 1 for (11, 3) is [8.559135101906912E-5]
0 to 1 for (11, 4) is [8.557256002536103E-5]
0 to 1 for (11, 5) is [8.55602682883699E-5]
0 to 1 for (11, 6) is [8.555222039216433E-5]
0 to 1 for (11, 7) is [8.554694566332781E-5]
0 to 1 for (11, 8) is [8.554348483303577E-5]
0 to 1 for (11, 9) is [8.554121173362674E-5]
0 to 1 for (11, 10) is [8.553971722241507E-5]
0 to 1 for (11, 11) is [8.553873366206768E-5]
0 to 1 for (11, 12) is [8.553808577512288E-5]
0 to 1 for (11, 13) is [8.553765863742363E-5]
0 to 1 for (11, 14) is [8.553737681138684E-5]
0 to 1 for (12, 1) is [8.56200986607846E-5]
0 to 1 for (12, 2) is [8.559135101906912E-5]
0 to 1 for (12, 3) is [8.557256002536103E-5]
0 to 1 for (12, 4) is [8.55602682883699E-5]
0 to 1 for (12, 5) is [8.555222039216433E-5]
0 to 1 for (12, 6) is [8.554694566332781E-5]
0 to 1 for (12, 7) is [8.554348483303577E-5]
0 to 1 for (12, 8) is [8.554121173362674E-5]
0 to 1 for (12, 9) is [8.553971722241507E-5]
0 to 1 for (12, 10) is [8.553873366206768E-5]
0 to 1 for (12, 11) is [8.553808577512288E-5]
0 to 1 for (12, 12) is [8.553765863742363E-5]
0 to 1 for (12, 13) is [8.553737681138684E-5]
0 to 1 for (12, 14) is [8.553719072539291E-5]
0 to 1 for (13, 1) is [8.559135101906912E-5]
0 to 1 for (13, 2) is [8.557256002536103E-5]
0 to 1 for (13, 3) is [8.55602682883699E-5]
0 to 1 for (13, 4) is [8.555222039216433E-5]
0 to 1 for (13, 5) is [8.554694566332781E-5]
0 to 1 for (13, 6) is [8.554348483303577E-5]
0 to 1 for (13, 7) is [8.554121173362674E-5]
0 to 1 for (13, 8) is [8.553971722241507E-5]
0 to 1 for (13, 9) is [8.553873366206768E-5]
0 to 1 for (13, 10) is [8.553808577512288E-5]
0 to 1 for (13, 11) is [8.553765863742363E-5]
0 to 1 for (13, 12) is [8.553737681138684E-5]
0 to 1 for (13, 13) is [8.553719072539291E-5]
0 to 1 for (13, 14) is [8.55370677716793E-5]
0 to 1 for (14, 1) is [8.557256002536103E-5]
0 to 1 for (14, 2) is [8.55602682883699E-5]
0 to 1 for (14, 3) is [8.555222039216433E-5]
0 to 1 for (14, 4) is [8.554694566332781E-5]
0 to 1 for (14, 5) is [8.554348483303577E-5]
0 to 1 for (14, 6) is [8.554121173362674E-5]
0 to 1 for (14, 7) is [8.553971722241507E-5]
0 to 1 for (14, 8) is [8.553873366206768E-5]
0 to 1 for (14, 9) is [8.553808577512288E-5]
0 to 1 for (14, 10) is [8.553765863742363E-5]
0 to 1 for (14, 11) is [8.553737681138684E-5]
0 to 1 for (14, 12) is [8.553719072539291E-5]
0 to 1 for (14, 13) is [8.55370677716793E-5]
0 to 1 for (14, 14) is [8.553698648067746E-5]
很抱歉问这么大的问题。如果我需要澄清更多,我会澄清,因为我不太擅长澄清。 我想提供尽可能多的信息,以帮助查看此代码的人员。真的,我再说一遍,我只是想修复反向传播功能,以免每次运行时网络输出都为1或0。
这是主要方法:
Network net = new Network(2,15,15,1); // 2 represents
String s = "1,7,1 3,13,0 4,2,1 4,4,0 4,8,0 8,5,1 10,8,0 12,3,0 12,11,1 11,2,1 13,6,0"; //some data
double[][] input = new double[s.split(" ").length][];
double[][] target = new double[s.split(" ").length][];
for (int i = 0; i < s.split(" ").length; i++) {
input[i] = new double[] {Double.parseDouble(s.split(" ")[i].split(",")[0]), Double.parseDouble(s.split(" ")[i].split(",")[1])};
target[i] = new double[] {Double.parseDouble(s.split(" ")[i].split(",")[2])};
System.out.println(Arrays.toString(input[i]) + " " + Arrays.toString(target[i]));
} // this stuff parses the data
for (int i = 0; i < 8000; i++) {
for (int j = 0; j < s.split(" ").length; j++) {
net.train(input[j], target[j], 0.3); //this method has issues for sure since it calls the other methods that I need help with
}
}
for (int x = 1; x < 15; x++) {
for (int y = 1; y < 15; y++) {
System.out.println("0 to 1 for (" + x + ", " + y + ") is " + Arrays.toString(net.calculate(new double[] {x, y})));
}
}
}