Skip to content

Instantly share code, notes, and snippets.

@RafayAK
Last active November 10, 2019 11:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RafayAK/85c6e3dbead1c57a013f118e7534dcd4 to your computer and use it in GitHub Desktop.
Save RafayAK/85c6e3dbead1c57a013f118e7534dcd4 to your computer and use it in GitHub Desktop.
training loop for iris data
costs = [] # initially empty list, this will store all the costs after a certain number of epochs
# Start training
for epoch in range(number_of_epochs):
# ------------------------- forward-prop -------------------------
Z1.forward(X_train)
A1.forward(Z1.Z)
# ---------------------- Compute Cost ----------------------------
cost, dZ1 = compute_stable_bce_cost(Y_train, Z1.Z)
# print and store Costs every 100 iterations and of the last iteration.
if (epoch % 100) == 0 or epoch == number_of_epochs - 1:
print("Cost at epoch#{}: {}".format(epoch, cost))
costs.append(cost)
# ------------------------- back-prop ----------------------------
Z1.backward(dZ1)
# ----------------------- Update weights and bias ----------------
Z1.update_params(learning_rate=learning_rate)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment