In the programming assignment for Week 2, I am stuck on implementing the cost function . The cost function is expressed as the summation, 1 to m , of two terms. Should I break that into two summations? Then I could use np.dot on each of the terms. Then multiply the whole thing by negative 1/m. Is this the right approach?
Yes, that sounds like the right approach. The Y = 1 term and the Y = 0 term are each a summation, that you can compute with a dot product (with the appropriate transpose) or by using elementwise multiply followed by np.sum to add up the elements. Then you add the two terms and multiply by -\frac {1}{m}.