I am trying to figure out why my code for the cost function is not working as it should. For some reason I just can´t figure out I just wont get the required solution no matter how I change my code.
I would like to post my code that gives me the Issues, am I allowed to do so?
No, you cannot share your code publicly (Code of Conduct).
Are you getting error messages, or just the wrong result value?
You can post a screen capture image that shows any errors or asserts. Sometimes that is sufficient to diagnose the problem.
I am just getting the wrong result. My result is “Cost at initial w and b (zeros): 0.007”. I hope that helps
I personally suspect that it is something about my sigmoid function, because it always gives the result 0 for every example in the training data
That is a good clue there is a problem.
Check for simple issues like returning the wrong variable name. Note that variable names in Python are case-sensitive.
no sadly enough that doesn´t seem to be the problem. But I just noticed that all my w-values are all 0. Should that be this way?
It depends on which test you are running.
A screen capture image that shows the results of running your code would be very helpful. Don’t include your code, just the results or any error messages.
well at least for the first test, the second test do that so that’s probably not it
Could you tell me how I could do that on my PC?
Just to clarify, you need instructions on how to make a screen capture image?
Yes, sorry I never needed that before. With screen capture Image you meen a screenshot right?
For example: I’m using Windows 10. It has a built-in “Snipping Tool”. You maybe can find it your applications. I keep it pinned to my toolbar. When I want to capture an image, I open the tool, click on “New”, then draw a rectangle around the area of interest. I then copy it, then paste it into my reply on the forum.
Thanks for the tip, that’s the result I get for the second test, but I don´t think that makes it all to clear, does it?
That’s the ticket. Nice work.
Your compute_cost function is failing the test that is in public_test.py, using the compute_cost_test() function.
If you want to see the data it is using, you can use the File menu, open the public_test.py file, and read the test. There you can find what X, y, w, and b values your code isn’t handling correctly.
Maybe you can work out the correct calculation on paper, and compare it to what your code is doing.
Adding some “print()” statements to your code can be very helpful in getting the results of calculations.
I found the mistake. I forgot an + symbol and instate of += just wrote = which always updated the variable to the new result instead of adding it to a total amount of the loss. I am horribly sorry for waste your time, but thank you very much for your help.
That’s good news!