Skip to content

Instantly share code, notes, and snippets.

@RafayAK RafayAK/training.py
Last active Nov 10, 2019

Embed
What would you like to do?
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
You can’t perform that action at this time.