Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 123571e

Browse files
TheSPARTAnorvig
authored andcommitted
Used learning_rate in gradient update for w (#284)
1 parent 0e46096 commit 123571e

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

learning.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -647,15 +647,14 @@ def Linearlearner(dataset, learning_rate=0.01, epochs=100):
647647
err = []
648648
# Pass over all examples
649649
for example in examples:
650-
x = [example[i] for i in range(idx_i)]
651-
x = [1] + x
650+
x = [1] + example
652651
y = dotproduct(w, x)
653652
t = example[idx_t]
654653
err.append(t - y)
655654

656655
# update weights
657656
for i in range(len(w)):
658-
w[i] = w[i] - dotproduct(err, X_col[i])
657+
w[i] = w[i] - learning_rate * dotproduct(err, X_col[i])
659658

660659
def predict(example):
661660
x = [1] + example

0 commit comments

Comments
 (0)