David Turvene
1 min readOct 3, 2019

--

Nice code but I couldn’t get it to work. Some comments

  1. show the dataset generation: I couldn’t get the shapes adjust to feed into the model.
  2. The gd function is a little screwy and creates numpy arrays. An alternative is to use the dot-product to update the slope and bias. Here’s an example def:

def mygd(x,y,w,b,lr=0.01,epochs=1000):
N = len(y)
barr = np.array([1]*N)
for it in range(epochs):
y_pred = x@w + b

dw = 1/N*(x.T@(y_pred-y))
db = 1/N*(barr@(y_pred-y))
w = w — lr*dw
b = b — lr*db

return w,b

--

--

David Turvene
David Turvene

Written by David Turvene

Experienced software engineer with a background in Linux, Embedded Systems, Telecom/Datacom, C/C++, Python. BSc CSE from University of Pennsylvania.

No responses yet