def cost_calculation(A2,Y): m = Y.shape[1] cost = (- 1 / m) * np.sum(Y * np.log(A2) + (1 - Y) * (np.log(1 - A2))) # compute cost return cost