#Take the error when label=1
class1_cost = -labels*np.log(predictions)
#Take the error when label=0
class2_cost = (1-labels)*np.log(1-predictions)
#Take the sum of both costs
cost = class1_cost + class2_cost
In this code, it seem like class1 return positive cost and class2 return negative cost, wouldn't they cancel when added?