Created
April 22, 2017 11:05
-
-
Save skyer9/eb8885a9dcf225ede2bc28ff083519fa to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x_train = [1., 2., 3., 4.] | |
y_train = [1.1, 2.1, 3.1, 4.1] | |
W, b = 123, 45 | |
learning_rate = 0.05 | |
for epoch in range(0, 200): | |
for j in range(0, len(x_train)): | |
cal_y = W * x_train[j] + b | |
error = (cal_y - y_train[j]) | |
W = W - learning_rate * x_train[j] * error | |
b = b - learning_rate * error | |
print('epoch: %i, W:%f, b:%f' % ((epoch + 1), W, b)) | |
print('result W * 5 + b = %f' % (W * 5 + b)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment