This is the notes when I study the Coursera class Neural Networks & Deep Learning by Andrew Ng, section Gradient descent on m training examples. Share it with you and hope it helps
Last class, you saw how to compute derivatives and implement gradient descent with respect to just one training example for logistic regression. Now, we'll do it for m training examples.
Recap the cost function of logistic regression:
And,
According to calculus equations:
So, above can be shown as below in figure-1 in programming:
Note that everything on figure-1 implements just one step of gradient descent. So you have to repeat everything on figure-1 multiple times in order to take multiple steps of gradient descent.
It turns out there are 2 weakness in these calculations: you need to write 2 for loops. The 1st is over the m training examples; the 2nd is over all the features. Having explicit for loops in the code makes your algorithm run less efficiency. In deep learning era, we would move to bigger and bigger data sets, so being able to implement your algorithms without using explicit for loops is really important and help you to scale to much bigger data sets. The technique vectorization allows you to get rid of these explicit for loops in the code.
<end>