import numpy as np
import math
import random
alpha = 0.01
x = np.array([[1,1],[0,0],[0,1],[1,0]])
t = np.array([1,0,0,0])
w1 = 0
w2 = 0
eps = 1e-4
e1 = 1
e2 = 1
sigmod = 1
#激活函数sigmod()
for i in range(0,4):
if e1 <=eps or e2 <= eps:
w1 -= alpha*e1
w2 -= alpha*e2
else:
sigmod = 1/(1+np.exp(-(w1*x[i][0]+w2*x[i][1])))
e1 = (sigmod-t[i])*sigmod*(1-sigmod)*x[i][0]
e2 = (sigmod-t[i])*sigmod*(1-sigmod)*x[i][1]
print(w1,w2)
0.00375 0.00375