C2 W2 / Epoch cost / Exercise 6

Tell me please, why do we devide epoch_cost over m in the 78th line of code?
We’ve already devided cost over num_examples in compute_cost function when applied reduce_mean :thinking:

Yes, this is a little bit confusing. It turns out that the compute_cost function they give us here does not do a reduce mean: it just gives the sum of the per sample costs. So what that logic does is accumulate the sum of the losses over all samples in all minibatches and then at the end of each epoch it converts it to the normal “average loss per sample” formulation of the cost.

You can confirm my statement about compute_cost by clicking “File → Open” and having a look at the imported utility python file.