728x90
반응형
x, w, b, yT, lr = 2, 3, 1, 10, 0.01
for epoch in range(2000):
y = (x * w) + (1 + b)
E = (y - yT) ** 2/2
yE = y - yT
wE = yE * x
bE = yE * 1
w = w - lr * wE
b = b - lr * bE
if E < 0.0000001:
break
print("epoch = %d" % epoch)
print("y = %6.3f" %y)
print("wE = %6.3f, bE = %6.3f" %(wE, bE))
print("w : %f, b : %f" %(w,b))
x1, x2 = 2, 3
w1, w2 = 3, 4
b, yT, lr = 1, 27, 0.01
for epoch in range(2000):
y = (x1 * w1) + (x2 * w2) + (1 + b)
E = (y - yT) ** 2 / 2
yE = y - yT;
x1E, x2E = yE - w1, yE - w2
w1E, w2E = yE * x1, yE * x2
bE = yE * 1
w1 -= lr * w1E
w2 -= lr * w2E
b -= lr * bE
print("epoch = %d" %epoch)
print("예측값(y) = %6.3f" %y)
print("가중치(w1) = %6.3f (w2) = %6.3f" %(w1, w2))
print("가중치 역전파(w1E) = %6.3f, (w2E) = %6.3f, 편향 역전파(bE) = %6.3f" %(w1E, w2E, bE))
if (E < 0.0000001):
break
728x90
반응형
'Deep Learning' 카테고리의 다른 글
Activation Function(sigmoid, relu, softmax) (0) | 2022.09.01 |
---|---|
Matrix and Calculation (0) | 2022.08.31 |
Deep Learning Basic Formula - 2input, 2output (epoch 1 ~ 200) (0) | 2022.08.24 |
Deep Learning Basic Formula - 2input, 1output (epoch 1 ~ 200) (0) | 2022.08.23 |
Deep Learning Basic Formula - 1input, 1output (epoch 1 ~ 200) (0) | 2022.08.23 |