L-Model Backward

Dear Sir I am getting the error as key error. I have missed something but not able to figure out.

(Solution code removed by staff)

Hi @Ravindranath,

Can you share your lab ID with me ? In the assignment, when you click the top right “Help” button, a panel will open and your lab ID will be shown at the bottom.

I shall take a look.

When you reply back, kindly tag me in the post so that I’m notified.

Thanks,
Mubsi

@ Mubsi Thank you I rectified mistake I will take your help in future if I am struck somewhere. Thank you for your kind consideration and reply

Hello, I also am getting an index error. It seems for some reason I can’t see on my source code that the grads dictionary is not being populated, at least not with dA0 -perhaps understandably so since we are on a supervised setting and dA0, as I understood it, refers to the derivatives on X but I think it’s there to just not break the symmetry of the code and have to deal with that edge case; Anyway, db1 is also not there when I run the test cell on a non-test cell. The other partials are being correctly recorded. Any ideas?

It sounds like your “for loop” logic must have some issues. Have another careful look and make sure to read the comments in the template code about what the inputs and outputs are at each level. On a given layer, let’s say layer 2, you take dA2 as an input and then you produce dW2, db2 and dA1 as outputs, right? So that means you will produce dA0 when you process layer 1, but that’s ok. You’re right that there is nothing useful we can do with dA0, but we still need dW1 and db1, right?

Indeed, thank you for your prompt response. one-off errors can really drive me crazy. Julia is a bit better with this, having adopted one-based indexing but there seem to be no having one’s cake and eating it too. Thanks again.

Yes, the 0 based indexing is one of the big things to get used to switching to python from Julia or MATLAB (another language with 1-based indexing). I came from the MATLAB direction, so I feel your pain on this although I have less of an excuse because I spent a long time writing in c (another 0-based language) earlier in my career. :nerd_face: