1 min readOct 3, 2019
Nice code but I couldn’t get it to work. Some comments
- show the dataset generation: I couldn’t get the shapes adjust to feed into the model.
- 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 + bdw = 1/N*(x.T@(y_pred-y))
db = 1/N*(barr@(y_pred-y))
w = w — lr*dw
b = b — lr*dbreturn w,b