Week 3 - Coding part, exercise 3

Hi all,

So, I’m having issues similar to the one found here (Week 3 assignment: bug in the test) with the following error ‘Tests failed on 6 cell(s)! These tests could be hidden. Please check your submission.’ as described on the post. Additionally it is caused by the third task within the notebook. Could it be that I’m struggling still with an older version of the notebook? Based on the prompts my notebook id is gqmzbdusqbiu. Any help from someone maintaining the notebook would be useful :smiley:

Thanks in advance!

That thread is huge and covers a number of topics going back several years.

Can you post all of the information about your specific issue here?

Include screen capture images of any error messages or asserts, or your test results.

Please do not include images of your code.

You probably have the most current notebook, if you started the course recently and got the notebook only through opening the assignment page.

If you got a copy of the notebook you found online, it could be anything. there have been lots of changes over time.

Hi, thanks for the swift reply! So, I’ll try to explain as follows:

  • In particular, I was referencing the issue mentioned on this comment - Week 3 assignment: bug in the test - #11 by dave_merit. Thanks for pointing out that there are more things here and to be more specific.
  • So based on that and what I saw on public_testsV2 + the third exercise “Initialize the parameters” I see that there is maybe a mismatch with the test cases causing it to fail. Initially, I started with the same error mentioned in the previous point → Wrong dimensions for W1.
  • After that I started toying around with the test cases and managed to get the following → Wrong values for W1
W1 = [[0.00435995 0.00025926]
[0.00549662 0.004353221
[0.00420368 0.003303351
[0.00204649 0.00619271]]
b1 = [[0.1
10.1
[0.]
10.11
W2 = [[0.00299655 0.00266827 0.00621134 0.0052914211
b2 = [[0.1]
n_x 2 n_h 4 n_y 1
[[0.00299655 0.00266827 0.00621134 0.0052914211
AssertionError
<ipython-input-23-0eb4c3a6d62e> in ‹module>
8 print ("b2 = " + str(parameters ["b2"]) )|
9
Traceback (most recent call last)
-> 10 initialize_parameters_test(initialize_parameters)
-/work/release/W3A1/public_tests.py in initialize_parameters_test(target)
assert parameters ["b2"] shape == expected_output ["b2"].shape, f"Wrong shape for b2."
54
-—-> 55|
56
57
assert np-allclose(parameters ["Wl"], expected_output ["W1"]), "Wrong values for Wl" assert np.allclose(parameters["b1"], expected_output ["b1"]), "Wrong values for bl" assert np.allclose(parameters("W2"], expected_output ["W2"]), "Wrong values for W2"|
  • Hint: Maybe with the provided notebook ID you can see also what I mean because I’ve changed a bit some values of the test that specific test case initialize_parameters_test.

Notice that all your values are positive. That means you used the wrong random function. The instructions tell you to use the np.random.randn, which gives a normal (Gaussian) distribution with \mu = 0 and \sigma = 1. That will give values that are both positive and negative and some of which may have absolute value > 1.

Also note that the b values should be zero, but yours are not.

The formatting of your output also doesn’t make sense. The braces don’t match on the b1 and b2 values. It looks like you are somehow interleaving multiple outputs there.

This causes you to fail the test case in the notebook, so there is no point in submitting to the grader until you fix the issues with the unit tests.

Sorry, but the mentors are just fellow student volunteers. We do not have the “superpower” to look at anyone else’s notebook. Only the course staff can do that.

3 Likes

Tip: Do not modify the test cases.

2 Likes

Yes, it looks like you modified that line. The “Wl” as opposed to “W1” there will not end well, if that’s what it really says.

But perhaps this is all just a side effect of the way you “copy/pasted” the data. Things look a bit scrambled, as I mentioned above.

If you actually modified the file public_tests.py, that is not a good idea. If so, you should use the “Get a clean copy” procedure here to revert to the standard version. If you read all the way through that post, it talks about the other files besides the notebook.

1 Like

Agree with @paulinpaloalto . Also check the shape of the parameters you are using do they match :red_question_mark:
Suggestion is to start with the fresh (clean copy) notebook.
Also, follow the suggestion given by @TMosh Tip: Do not modify the test cases.

2 Likes

Hi all,

First of all thanks for the joint effort in clarifying the key points! Yes, the main issue related to using the wrong rand function. So by changing that, and reverting the test cases, everything was OK! But additional things pointed out in this discussion are overall valuable info for the future!

Thank you all once again!

2 Likes