Logistic Regression with a Neural Network mindset Confused

Help !

I can’t understand the Logistic_Regression_with_a_Neural_Network_mindset
and stuck at 4.3 Forward and Backward propagation.

As the Hint: cost function = -1/m times the sum of "loss function "

The loss function is -[y(i) * log(a(i)) + (1-Y(i)) * log(1-A(i))]

so I write code like :

{moderator edit - solution code removed}

But its result is wrong ,
the correct answer is :

{moderator edit - solution code removed}

I am so confused about np.dot , np.sum, or just element-wise calculation or others , I could google out what difference between them but still feel confused in such usage way. Is there any help ?

Thanks so much ~~

Link below:
My

Either of those implementations should work. It’s just a question of turning math formulas into linear algebra expressions and then turn those into correct python code.

np.dot will multiply the corresponding terms of two vectors together and then add up the products. So it’s a single operation that does both multiply and add.

Or you can write it as two steps: elementwise multiply (“*”) between each pair of the vectors and then use np.sum to add up the products.

Also please realize that no-one else can directly look at your notebooks. We also are not allowed to discuss solution code on a public thread. If we need to discuss the details of why your np.dot code did not work, there are private ways to do that.

Thank you for your quick reply!
I just tried, you’re right!
Maybe my answer had typo, I type again and the result is right!

1 Like

That’s good news! Thanks for confirming. This is just the beginning and there is a lot of interesting material ahead. Onward! :nerd_face:

Got it and sorry for that.
What’s Private way for questions about source code?

If the mentors need to look at your source code in order to help, we will send you a “DM” or private message. Those show up in your message “feed” but can be recognized by the little “envelope” icons.

To send a DM to someone else, you first click on their name or avatar and then click the “Message” button.

1 Like