C1_W3 final lab- compute_cost_test not defined

I’m finishing up with the final Jup lab, when I ran into this erro–

NameError Traceback (most recent call last)
in
8
9 # UNIT TESTS
—> 10 compute_cost_test(compute_cost)

NameError: name ‘compute_cost_test’ is not defined

the compute_cost_test function lives in an asscoicated.py file

Also, you can see that my code passed the previous test–

Cost at initial w and b (zeros): 0.693

Expected Output:

Cost at initial w and b (zeros) 0.693

1 Like

Make sure you have run all the cell from beginning till the cell you are having issue.

kindly run the grader cell mention compute cost

Okay. did that. thanks.

now that cell is throwing this error–

Cost at test w and b (non-zeros): 5.526

AssertionError Traceback (most recent call last)
in
8
9 # UNIT TESTS
—> 10 compute_cost_test(compute_cost)

~/work/public_tests.py in compute_cost_test(target)
24 b = 0
25 result = target(X, y, w, b)
—> 26 assert np.isclose(result, 2.15510667), f"Wrong output. Expected: {2.15510667} got: {result}"
27
28 X = np.random.randn(4, 3)

AssertionError: Wrong output. Expected: 2.15510667 got: 1.597429473694739

1 Like

One step at a time: now you got the test to run, but what it’s telling you is that your code is incorrect. The first step is to compare your code carefully to the mathematical formula for the cost shown in the instructions. There must be some difference between what you wrote and what the formulas say.

1 Like

Hello Kieth,

Check your codes for z_wb if you have initiated at the correct value and then subsequently at
Add the corresponding term to z_wb

Regards
DP

I’ve done my best with reviewing the code, which admittedly isn’t stellar as my primary experience with python is working with python data science libraries.

anyway, I’m glad to have the opp to learn these lessons, only I have no way thinking my way through this code other than viewing the hints.

Here is my code. If you see something off in the code, please give me some hints. But, I’m pretty sure it’s correct. both of these code block passed the tests, except the one under discussion. I appreciate ya guys!

{moderator edit - solution code removed}

1 Like

Don’t you need to accumulate the z_wb values in the “for” loop? The way you wrote the code, you end up only with the very last one.

Also just as a general matter, note that the rules are that we can’t just post our code publicly and say (in effect) “please fix it for me!” If the mentors can’t help without seeing your code, there are private ways to do that using “direct messages”.

No harm is really done for the moment, since I can edit your post to hide the code.

sorry, paul. I won’t do it again. These are my first postings. I’m beginning to be concerned as to whether continuing in the series is for me. I’m nowhere near being a software engineer. I can only imaging the courses all the way to the advanced deep learning one’s the programming skills become more-n-more demanding.

Thank you for your hint. I got it fixed :slight_smile:

You’re right that real programming skills are required if you want to go all the way through MLS and DLS. Of course developing your python skills can be a positive thing overall, but you have to be committed to investing the effort in that as well as understanding the DL concepts.

It’s great news that you found the solution based on that hint. The rest of the code did look correct, although I am not actually a mentor for MLS, so I’m going out on a limb a bit here. :grinning: Onward!

Any suggestion on where to start to back-fill my “structured” python programming deficiencies, with a book or two or course. I’m not giving up even if I have to pause, and back up, retool and move on.

It depends on how much other programming experience you have. If you know any other languages like JavaScript or C# or C, then you can probably just spend some time reading python documentation and tutorials. python.org is a rich source of both.

But if python is your first language, then it’s probably better to take a course. There are lots available, but I haven’t personally taken any of them. Just searching for python courses on Coursera turns up quite a few, including ones that are particularly targeted at ML/DL programming. I was actually a programmer from the age of 14 (now retired), so came to python pretty late in life already knowing lots of languages, so I just read some of the python.org materials and did the “learn on the job” strategy.

my first language was php. I did web application dev. But, i wasn’t much more adept at php than I am now with python. I’ll take you up on your advice get myself enrolled in a foundational python specialization. All the best, buddy.

1 Like