Hi I am trying to implement the nn_model the line of code asked is:
# Forward propagation. Inputs: “X, parameters”. Outputs: “A2, cache”.
# A2, cache = …
I am struggling to start. Could you give me a hint? copy A2 and cache from previous questions? Concerning cache, should I rewrite the formula for Z1?
Welcome to the Specialization @Rogelio. In these lines, you will be using the “helper functions” that you implemented earlier in the notebook. For e.g.,
A2, cache = my_function(arg1, arg2, ...),
where the arguments to the function (arg1, …) are to be inherited from the arguments to the nn_model(...) function or are otherwise computed within the body of the function.
Thank you @kenb for your advise! I am really enjoying the specialization!
I implemented the “helper functions” into nn_model(…). When I run the test, I get the following error message: “TypeError: loop of ufunc does not support argument 0 of type dict which has no callable log method” It looks like it is related to the compute_cost (A2, Y) function, in particular to logprobs = np.multiply (np.log(A2), Y). Any idea of what is happening? Thanks!
At this point, all I can suggest is that you examine your compute_cost function very carefully. From personal experience, I have noticed that using dot products and using transposes (you can write the expression in one line rather than two) has worked out better. I have no idea why.
You are right. I reviewed my code and found the mistake: inside Def nn_model(…) I wrote cache, A2 = forward_propagation(…), Instead of A2, cache = forward_propagation(…)
It now works an I passed the assignment! Indeed, we have to be careful with the order in which we right the parameters and variables.
Thks for your help!
Thanks for the follow-up @Rogelio. I was a bit suspicious of my advice, and I am glad that you found the error that actually makes sense to me! Onwards!