Course1_Week4_Assignment2_Ex1

Cost after first iteration: 0.693049735659989
Error: Wrong output for variable b2.
Error: Wrong output for variable W1.
Error: Wrong output for variable b1.
Error: Wrong output for variable W2.
Error: Wrong output for variable b2.
1 Tests passed
3 Tests failed

AssertionError Traceback (most recent call last)
in
3 print("Cost after first iteration: " + str(costs[0]))
4
----> 5 two_layer_model_test(two_layer_model)

~/work/release/W4A2/public_tests.py in two_layer_model_test(target)
75 ]
76
ā€”> 77 multiple_test(test_cases, target)
78
79

~/work/release/W4A2/test_utils.py in multiple_test(test_cases, target)
140 print(ā€˜\033[92mā€™, success," Tests passed")
141 print(ā€˜\033[91mā€™, len(test_cases) - success, " Tests failed")
ā†’ 142 raise AssertionError(ā€œNot all tests were passed for {}. Check your equations and avoid using global variables inside the function.ā€.format(target.name))
143

AssertionError: Not all tests were passed for two_layer_model. Check your equations and avoid using global variables inside the function.

iā€™m facing this problem after running the code.
iā€™m using initialize_parameters and the costs[0] is numpy ndarray object

Are you sure you are calling all the below functions correctly? With correct arguments and activation function?

Yes, I am sure about everything; all the other cells are giving the true outputs, like:
Cost after iteration 0: 0.693049735659989
Cost after iteration 100: 0.6464320953428849
Cost after iteration 200: 0.6325140647912677
Cost after iteration 300: 0.6015024920354665
Cost after iteration 400: 0.5601966311605747
Cost after iteration 500: 0.5158304772764729
Cost after iteration 600: 0.4754901313943325
Cost after iteration 700: 0.43391631512257495
Cost after iteration 800: 0.4007977536203886
Cost after iteration 900: 0.3580705011323798
Cost after iteration 1000: 0.3394281538366413
Cost after iteration 1100: 0.30527536361962654
Cost after iteration 1200: 0.2749137728213015
Cost after iteration 1300: 0.2468176821061484
Cost after iteration 1400: 0.19850735037466102
Cost after iteration 1500: 0.17448318112556638
Cost after iteration 1600: 0.1708076297809692
Cost after iteration 1700: 0.11306524562164715
Cost after iteration 1800: 0.09629426845937156
Cost after iteration 1900: 0.0834261795972687
Cost after iteration 2000: 0.07439078704319085
Cost after iteration 2100: 0.06630748132267933
Cost after iteration 2200: 0.05919329501038172
Cost after iteration 2300: 0.053361403485605606
Cost after iteration 2400: 0.04855478562877019
Cost after iteration 2499: 0.04421498215868956

and the accuracy of the training and testing are the same as the expected output.
Also, the second exercise is giving me All tests passed

Please double check that you did not use the ā€œdeepā€ version of the initialization function in the ā€œtwo layerā€ case. In this notebook, the function they provided for the ā€œdeepā€ case uses a more sophisticated algorithm. It generates better results if you use it in the two layer case, but you fail the tests because the expected results donā€™t match.

1 Like

Iā€™m using parameters = initialize_parameters(n_x = n_x, n_h = n_h, n_y = n_y) this function.
when i try initilaize_parameters_deep it gives me another error message initialize_parameters_deep() got an unexpected keyword argument 'n_x

Well, the arguments to initialize_parameters_deep are different: you pass a single ā€œtupleā€ with the dimensions, right?

Maybe itā€™s time to look at your code. We canā€™t do that here in on a public thread, but there are private ways to do that. Please check your DMs for a message from me about how to proceed.

1 Like

To close the loop on the public thread, there were a couple of problems that were caused by changing code outside the ā€œYOUR CODE HEREā€ sections. Itā€™s not illegal to add things (e.g. print statements) outside the ā€œYOUR CODE HEREā€ sections, but itā€™s very important that you are careful to understand what you are doing when you ā€œgo thereā€. Especially if you are actually changing existing logic given in the template code: that usually does not end well. :scream_cat:

1 Like