On Section 4.4 - Compute the Cost, the formula for J was given and we were asked to compute the cost through code. I was able to complete this section using ‘np.multiply(np.log(A2, Y)’ but the text also suggested that it is possible to implement this using np.dot directly. Can someone show a solution on how to do this or maybe a clue on how to approach this using np.dot only?
Here it is.
The first case is to use “multiplication” and “summation”, and the second case is “dot product” only.
One thing that you need to be careful is, you may need to transpose one vector like above.
Thanks for the response! I understood that part. What confused me is the two sums after the product of y,log(a) and how to do that in single dot product.
(y,log(a1)) + ((1-y) * log(1-a))
Those are two separate dot products. I believe it does not say that one single np.dot() can cover whole equation, but only says that np.multiply()+np.sum() can be replaced by np.dot().