In original notebook, there is no code to set the seed in initialize_parameters(). Where did you get it ?
nn_model() sets the seed to 3 at the top of the code. So, initialize_parameters() in nn_model() should inherit this setting, i.e, seed=3. The root cause is you put the np.random.seed(2) in initialize_parameters().
Yes, Iâve removed the parameters argument from cost function. Thank you.
It clearly said that the shape of your A2 is (1,3). Since the shape of Y is (1,400), it does not work. It needs to be the same shape as Y or the shape that Python can broadcast.
Assuming that A2 comes from forward_propagation() just before calling compute_cost(), the problem should be in there. Do you have any fixed parameter in there ?
I think it is better for you to trace the shape of A2 in both nn_model() and forward_propagation().
Thank you for your reply Nobu_Asai. There are no fixed parameters I guess. Here are the screenshots for the forward_propagation and cost function. I couldnât figure it out by myself. All the test are passed except 5.2 Here Iâve attached 3 screenshorts for the forward, backward and cost function. Thank you.
{moderator edit - solution code removed}
Thank you.
At first , please delete all code. It is not recommended in this community.
I will send my thought shortly.
Your notebook has lots of âtrial and errorsâ. Again, it is better to clean up. Otherwise, no one can predict what will happen.
The most problematic portion is you mixed up global variables and variables inside classes/functions. For example, there is no parameter t_X passed to forward_propagation(). You needs to use parameters passed. In this case, that should be X. As the fact, the shape of t_X in global variables is (2,3). But, the shape of X is different. It should pass the first test which uses t_X, but it should not for others.
In addition, there are still some âdebrisâ in compute_cost(). I remember you added one argument in here. And, there are still some code that refer âparameterâ. In this case, you refer a global variable. If everything is cleaned up, then, those may cause unexpected errors.
Anyway, the first thing to do is, of course, remove code in here, which is not recommended in this community. Then, 2nd thing to do is, to replace t_X, a global variable, by X, which is passed to forward_propagation().
Thank you so much Nobu_Asai yeah the problem was with forward_propagation function, I had used global variable. Now it is all fixed. Once again youâre the best.
Thank you.
I would like to ask last question, is it possible to revert the notebook to the original file which discards all the changes that we made.
Thank you.
Good to know that you completed this assignment !
Here is a good article which may help you. FAQ: Frequently Asked Questions for all DLS Courses
Good luck !
hey,Sara,I got exactly the same output with you. Did you figure out the problem? thx.
Hi, Phoebe.
In Saraâs case, it turned out there was an error in that one of the variable names used to hold the return values from one of the functions called by nn_model was misspelled, so the later code ended up using a global variable.
Of course programming has lots of âdegrees of freedomâ, so that means the number of potentially different mistakes one can make is pretty large. If the hint I gave above doesnât get you anywhere, let us know and weâll go from there.
OMG! I did misspelled a variable names! Now it worked ! Thank you very much!!!
Wow, so it really was the same kind of mistake to get the same result. So glad to hear that hint was enough for you to find the solution! Onward!
Hi @Jitendra_Bansal I have the same problem exactly with you please what is the mistake??
I am looking at this since 2 days but I have the same problem
@Bernardin_Tamo_Amoug If your error is on backward_propagation, there are a number of common mistakes there. Start by checking your implementation of dZ1 carefully. Are you sure you used W2 there and not dW2? Also check your implementation of g^{[1]'}(Z^{[1]}) in that formula: it is not equal to (1 - Z1^2), right?
Those are the most common two mistakes I can think of. If thatâs doesnât help, then weâll go to the next step.
@paulinpaloalto thank you for your help.I found my mistake
Thatâs great news! Thanks for confirming.
Hello, I think there may be a bug on exercise 6 test suite because I get a KeyError: A1
when unpacking parameters["A*"]
. When on a new cell I inspect the parameters
dictionary returned by backward_propagation_test_case
I get
Which seem to me be the initialised parameters, not the updated ones after running forward_propagation
at least once, which would contain A*
.
So is this a bug or am I missing something?