gpt4 book ai didi

python - 神经网络用一个神经元预测不良

转载 作者:行者123 更新时间:2023-11-30 09:00:18 25 4
gpt4 key购买 nike

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

在我的神经网络中,我想预测单个输入的单个输出我尝试将偏差和学习率设置为不同的值,但没有用

权重不断增加,错误率不断下降,但网络无法达到目标输出

最佳答案

你的 sigmoid 定义是错误的。应该是

def sigmoid(x):
return 1/(1+(math.e**(-x)))

您应该将一除以(一+指数);相反,您将一一相除,然后将指数添加到除法的结果上(显然是 1)。

关于python - 神经网络用一个神经元预测不良,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42787938/

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