Hi there,

For the two_layer_model, I kept getting this following error:

Cost after iteration 1: 0.6564026188409187

Cost after first iteration: 0.6950464961800915

Cost after iteration 1: 0.7239781229671559

Cost after iteration 1: 0.7239781229671559

Cost after iteration 1: 0.7239781229671559

Error: Wrong output for variable W1.

Error: Wrong output for variable b1.

Error: Wrong output for variable W2.

Error: Wrong output for variable b2.

Error: Wrong output for variable 0.

Cost after iteration 2: 0.6372332154479152

Error: Wrong output for variable W1.

Error: Wrong output for variable b1.

Error: Wrong output for variable W2.

Error: Wrong output for variable b2.

Error: Wrong output for variable 0.

2 Tests passed

2 Tests failed

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

I examined my whole code and donâ€™t think I used only the input variables, specifically, I used learning_rate as update_parameters(parameters, grads, learning_rate). On the other hand, for the L_layer_model, the same code pass test without error.

Can somehow help find out whatâ€™s wrong? Thanks!

Lu

Hey @Lu_Huang,

Welcome to the community. Can you please DM your code for the `two_layer_model`

function to me, so that I can help you figure out the issue.

Cheers,

Elemento

Just did, thanks a lot for the quick reply!

Hey @Lu_Huang,

You have used the `initialize_parameters_deep`

function instead of the `initialize_parameters`

function in your `two_layer_model`

function. The former function is for the L-layered model, while the later is for the 2-layered model. Also, when you are passing arguments to the `initialize_parameters`

function, you are supposed to pass them individually, whereas you have passed them as a tuple. I hope this helps.

Cheers,

Elemento

Oh, got it, thanks a lot for the help!

Wait, for the assignment we are dealing with here, initialize_parameters and initialize_parameters_deep have exactly same logic, is the difference because of random seed?

Hey @Lu_Huang,

If you check out the implementations of `initialize_parameters`

and `initialize_parameters_deep`

that have been imported and used in this assignment (*which you can view in the *`dnn_app_utils_v3.py`

file), you will find that in both the cases, the random seed is the same, and in fact, the implementations slightly differ which gives rise to this error.

Had you been using the functions that you implemented yourself in the previous assignment, the difference would indeed be of random seed, but in this case, it is not as I just mentioned before.

Feel free to check out the imported implementations and see the difference. Now, as to why this difference is done, perhaps the developers might have received better performance by the L-layered model by incorporating this difference. Once again, feel free to use your implemented functions, and see if this difference gives any advantage or not. Do share your results with the community.

Cheers,

Elemento

Exactly. It turns out that if you use the â€śplain vanillaâ€ť version of `initialize_parameters_deep`

that they had us build in the â€śStep by Stepâ€ť exercise, you get really terrible convergence for the 4 layer model here. So they used a more sophisticated algorithm called Xavier Initialization that we will learn about in Course 2 of this series, so stay tuned for that. I think they didnâ€™t mention this just because there is already enough new material to be learned in Course 1 and they didnâ€™t want to further muddy the waters. Well that and Iâ€™m guessing they didnâ€™t want to reveal that theyâ€™d given you the worked answers for the â€śStep by Stepâ€ť exercise as an â€śimportâ€ť file in the W4 A2 assignment. Of course if youâ€™d copied the â€śdeep initâ€ť code, it would have failed the tests in â€śStep by Stepâ€ť because the algorithm is different.

2 Likes