Reputation: 39
I was trying to implement a cost function for a Programming assignment in Andrew Ng Deep Learning course which requires my own, original work. I am also not allowed to reproduce the assignment code without permission, but am doing so anyway in this question.
The expected result for the cost = 6.000064773192205, But with this code, my result for cost = 4.50006477319. Does anyone have any idea what I did wrong in this code?
removed code
Upvotes: 2
Views: 5427
Reputation: 21
np.sum(np.multiply(Y, np.log(A)) + np.multiply((1-Y), np.log(1-A))) /m
Upvotes: 2
Reputation: 1
Just in case you find it useful (and as I'm doing the same source), you could also have called the sigmoid() function you defined in the previous step from within propagate() by using this instead:
A = sigmoid(np.dot(w.T,X) + b)
It's not necessary as evidenced by your work, but it's a bit cleaner.
Upvotes: 0
Reputation: 91
There is an error in your sigmoid function. You are supposed to calculate negative of np.dot(np.transpose(w), X) + b)
.
Here is the one I have used
A = 1 / (1 + np.exp(-(np.dot(np.transpose(w), X) + b)))
Upvotes: 2