This commit is contained in:
Morten Hjorth-Jensen
2021-11-05 06:42:12 +01:00
parent 4565722caf
commit dae1ce2b13
9 changed files with 922 additions and 567 deletions
+3 -3
View File
@@ -1039,9 +1039,9 @@ theta = np.random.randn(2,1)
for epoch in range(n_epochs):
# Can you figure out a better way of setting up the contributions to each batch?
for i in range(m):
random_index = np.random.randint(m)
xi = X[random_index*M:random_index*M+M]
yi = y[random_index*M:random_index*M+M]
random_index = M*np.random.randint(m)
xi = X[random_index:random_index+M]
yi = y[random_index:random_index+M]
gradients = (2.0/M)*training_gradient(yi, xi, theta)
eta = learning_schedule(epoch*m+i)
theta = theta - eta*gradients