Hi, so I wrote the functions for exercise 4 and it seems to not work for some reason… Would it be possible to help me out? Thanks! image|690x437
idk if im allowed to share my code, but if I am allowed I will be happy to share my code.
nvm, it works now. I made it work by replacing layers_dim with the three dimensions…
Hello @tfu, I have exactly the same behavior as your image|690x437
But replacing layers_dim with the three dimensions as an array(list) did not change anything for me. I bump into the “2 Tests passed, 1 Tests failed” with “Error: Wrong output for variables W1,b1,W2,b2 and 0”…
My problem output (as text, seems identical to image|690x437 ) is:
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.
2 Tests passed
1 Tests failed
---------------------------------------------------------------------------
AssertionError -------------------- Traceback (most recent call last)
<ipython-input-32-f9ec5304d38d> in <module>
-—| 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)
-–| 54 ]
-–| 55
- → 56 multiple_test(test_cases, target)
-–| 57
-–| 58~/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__))
–| 143AssertionError: Not all tests were passed for two_layer_model. Check your equations and avoid using global variables inside the function.
Note: the “cost” @tfu and I obtained on “first” iteration indicated on this post: https://community.deeplearning.ai/t/week-4-exercise-4-not-passing-both-tests/11880
- @tfu 0.6950464961800915 Post#1 Jun 4, 5:20 PM
- @dvnicolasdh 0.6950464961800915 Post#4 Jun 7, 2:53 AM
(hence iteration 0) seems the same as other people indicated on post https://community.deeplearning.ai/t/course-1-week-4-programming-assignment-2/5587
- @michael.brent 0.695046 (first post) Post#1 May 13, 6:46 PM
- @Sihan 0.695 Post#3 May 14, 3:55 PM
- @tt147 0.6950464961800915 Post#5 May 17, 12:36 AM
although @michael.brent seems to have obtained
a different iteration 0 cost 0.6930497356599888 on Post#6 May 23, 1:03 PM
although also @tfu may have obtained
a different iteration 0 cost ??? on Post#3 Jun 4, 5:31 PM
Guess I did not see the “subtlety” in @tfu statement. The meaning of replacing layers_dim with the three dimensions implied using the appropriate “function” as mentioned in the preceeding cell. I had been using the wrong initialization function (that worked with layers_dim instead of the three dimensions), taking the one instructed for the L_layer_model instead of the one instructed for the two_layer_model, probably after having scrolled up and down too much (and probably after having been distracted at the wrong time).
sorry! i just saw your message! were you able to solve your problem?
I also have the same issue, could you please explain how you solved it? I don’t really understand your explanation on layers_dim vs three dimensions.
ok so layers_dim is the dimension of the layers which is a tuple made of three parameters already defined for you.
Oh I see! How did you fix the problem?
I’m having the same problem. My code seems correct as the 2 layer model training produces the correct Cost after iteration 2499: 0.04421498215868956 and correctly predicts the testing data at 72%. But I get the following error message:
Cost after iteration 1: 0.6926114346158595
Cost after first iteration: 0.693049735659989
Cost after iteration 1: 0.6915746967050506
Cost after iteration 1: 0.6915746967050506
Cost after iteration 1: 0.6915746967050506
Cost after iteration 2: 0.6899956541494738
Error: Wrong output for variable W1.
Error: Wrong output for variable b1.
Error: Wrong output for variable W2.
Error: Wrong output for variable b2.
3 Tests passed
1 Tests failed
My problem is not the layers_dim discussed above. Any hints. I don’t think I’m supposed to paste code here but I can’t seem to find the solution myself. Additionally, I’m having the same problem for the 4 layer model, although, my code matches the Cost after iteration 2499 and prediction perfectly. How is this possible? Thanks
Hi, @Romaricin. This problem is often the case of “hard-coding” a keyword argument of the function (in this case two-layer-model
) into an argument to a function call within the function. To “inherit” the argument from the main function (two-layer-model
) , rather then hardcoding the default value as set up in the signature of the main function, one must not place the default value in the function called by the main function. Example: learning_rate = learning_rate
, not learning_rate=0.0075.
Got it. Thank you for your time
I had the same problem - thanks for your message - I could solve it now!
Hello sir, I am constantly getting “AssertionError: Not all tests were passed for two_layer_model. Check your equations and avoid using global variables inside the function.” this error and i am not able to solve it. It would be great if could help me
I am having kinda the same problem. Just before | 4.1 - Train the model| no plot function runs and I can not see my plots. and after this to train my model even I don’t see any errors but it does not run either, and every section name “In ” turns to “In [*]” and that is so strange.
at first it was all about the submit assignment button which I finally solved it with the kernel tab, now this is happening
hi Paarth, i am also having similar problem. were you able to solve this issue ?
Kind regards,
Venkaatesh
Hi @Venkaatesh_Durairaj, if you will use hard-coding values instead of the asked parameters passed into the function, it will show some of the tests as passed, but could fail the assertions for value comparisons. So, look out for the equations in case you are using any of the global variables. Thanks!
hi Rashmi,
Thanks for your response. i dont think i have used global variable anywhere. i have been looking at it the whole day, still could not figure out.
in the attached image, you may see that same tests with same parameters are carried out 2 times, in that one gives error and other 1 does not. Hence i am even more puzzled. Any light on this matter will be really helpful.
Hi @Venkaatesh_Durairaj, did you copy/paste anywhere? or did you miss running the cells using shift+enter key which is one of the necessities in jupyter notebook. Missing this approach will generate the output from the older values and will not synchronize as per the expected one. Thanks.
hi Rashmi,
Thank you. i think i realized the problem. there was one place where i had copy/pasted by mistake. it works fine now… Have a good day.
Kind regards,
Venkaatesh