Skip to content

Commit fadec32

Browse files
authored
Update lreg.py
1 parent 8fd9c04 commit fadec32

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lreg.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010

1111
to_np_array = lambda x, shape: np.array(x).reshape(shape)
1212

13-
N = 3000
14-
1513
# convert to numpy arrays
1614
x_train = to_np_array(x_train, [-1, 28 * 28])
1715
y_train = to_np_array(y_train, [-1, 1])
@@ -54,6 +52,8 @@ def loss_fn(self, yh, y):
5452
def train(model: LinearReg, train_data: tuple, epochs: int = 2, verbose: bool = False, train_with_bias: bool = False):
5553
assert len(train_data) == 2
5654

55+
lrate = 9e-9
56+
5757
if train_with_bias:
5858
assert model.bias == True, 'The bias parameter is not enabled.'
5959

@@ -90,15 +90,15 @@ def train(model: LinearReg, train_data: tuple, epochs: int = 2, verbose: bool =
9090
dJdA /= N
9191

9292
# update A
93-
model.A -= 9e-9 * dJdA
93+
model.A -= lrate * dJdA
9494

9595
if train_with_bias:
9696
""" Update Bias --- declare dJdB somewhere and make sure the shape is correct...."""
9797
# what should we with dJdB before updating B?
9898
# hint: Look at line 90
9999
# ask yourself, why we need to do that
100100

101-
#model.B -= 9e-9 * dJdB
101+
#model.B -= lrate * dJdB
102102

103103
if verbose:
104104
print("Training iteration:", epoch + 1, "Loss:", float(loss))

0 commit comments

Comments
 (0)