Skip to content

Commit

Permalink
Update 05_1_gradientdescent_manually.py
Browse files Browse the repository at this point in the history
bug fix in gradient calculation
  • Loading branch information
guidogallopyn authored Oct 26, 2021
1 parent e6dd99c commit c3b0a21
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion 05_1_gradientdescent_manually.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def loss(y, y_pred):
# J = MSE = 1/N * (w*x - y)**2
# dJ/dw = 1/N * 2x(w*x - y)
def gradient(x, y, y_pred):
return np.dot(2*x, y_pred - y).mean()
return np.mean(2*x*(y_pred - y))

print(f'Prediction before training: f(5) = {forward(5):.3f}')

Expand Down

0 comments on commit c3b0a21

Please sign in to comment.