import math
inp = 0.1
target = 0.3
weight = 0.04
learning_rate = 1
bias = 0
def sigmoid(x):
return (1/1+(math.e**(-x)))
for count in range(10):
net = (weight*inp)+(bias*1)
out = sigmoid(net)
error_total = 0.5*((target - out)**2)
print('error',error_total,'|| output',out,'|| weight',weight)
adjustment = (out - target)*(out)*(1 - out)*(inp)
weight = weight - (learning_rate*(adjustment))
输出
error 1.4382215499593243 || output 1.9960079893439915 || weight 0.04
error 1.3827597601324302 || output 1.9629851232842885 || weight 0.3771731560625728
error 1.3336445885853887 || output 1.9331837548698485 || weight 0.6915314696982848
error 1.2897634204261337 || output 1.9060905456580794 || weight 0.9861603791287348
error 1.2502583453938265 || output 1.8813022136162503 || weight 1.2635467711722324
error 1.2144557693222424 || output 1.8584965635651831 || weight 1.5257260148874747
error 1.1818184468701014 || output 1.8374124019729394 || weight 1.7743861541249517
error 1.1519119478941984 || output 1.8178352663541577 || weight 2.0109434853536103
error 1.1243806861957226 || output 1.7995870672926748 || weight 2.2365985045783425
error 1.0989304444985601 || output 1.7825184278777517 || weight 2.4523780684160923
在我的神经网络中,我想预测单个输入上的单个输出 我尝试将偏见和学习率设置为不同的值但没有用
并且权重继续增加且错误率降低但网络无法达到目标输出
答案 0 :(得分:2)
你的sigmoid定义是错误的。应该是
def sigmoid(x):
return 1/(1+(math.e**(-x)))
你应该除以(一个+指数);相反,你逐个划分,并将指数加到除法的结果上(显然是1)。
答案 1 :(得分:0)
将学习率更改为0.1或0.001。它不应该是<= 1