小编Reg*_*eño的帖子

我有一个无限的 while 循环,但我不明白为什么

我正在尝试学习如何从头开始编写非常简单的神经网络。但是我看不到如何进行正确的培训。每当我运行 while 循环时,它就会陷入无限循环。这是我的代码:

#inputs and targets
x1=[1,0,1]
x2=[0,1,0]
x3=[0,0,1]
inputs=[x1,x2,x3]
targets=[1,0,0,1]

#parameters
np.random.seed(1)
w1 = np.random.random_sample(size = 3)
w1=w1.tolist()
alpha=0.1
itera=0

#activation function
def purelin(z):
    return z

#network
def red(i,w1):
    n=[]
    for inp in i:
        a=inp*w1[inputs.index(i)]
        n.append(a)
    n=sum(n) #sumar inputs*weights (caso sin bias)
    a=purelin(n)
    return a

#forward propagation
def forw(inputs):
    outputs=[]
    for i in inputs:
        x=red(i,w1)
        outputs.append(x)
    return outputs

#error
def error(targets, outputs):
    e=[]
    zip_object = zip(targets, outputs)
    for i, j in zip_object:
        e.append(i-j)
    return e 


#backpropagation 
def back(e):
    w1_=[] …
Run Code Online (Sandbox Code Playgroud)

python while-loop neural-network deep-learning

-1
推荐指数
1
解决办法
128
查看次数