DLS 1, Week 4, Exercise 5

I am trying to trouble shoot my issue here but i cannot seem to find my problem. I understand the process on going through looking for matrix errors however I am not even sure how to approach this issue. Any help to debug my code below is much appreciated.

I looked through the post at ( Week 4 - L_layer_model - Deep Learning Specialization / DLS Course 1 - DeepLearning.AI) but I dont understand how to use that to approach my issue.

{moderator edit - solution code removed}

The problem is that you have structured the code such that the code for the output layer is also part of the “for” loop, so it is getting executed every time. That will not end well. Also note that once you split it out of the loop, you also have to be careful what the value of A_prev will be when you hit that line of code.

Indentation is a key part of the syntax in python: they use that to delimit what would be called “blocks” in a more structured language. It’s a bit annoying and Guido claims there’s a real reason for doing it this way, but his explanation sounds to me like a self-serving excuse for being too lazy to implement a real parser. But that’s just my opinion and worth exactly what you paid for it. :laughing:

Thank you for the help. I think i have narrowed my problem closer. Can you confirm? I am having troubles understanding what this input should be. (circled in blue)

{moderator edit - solution code removed}

The A value there is supposed to be the output of the last of the hidden layers, right? So I would say you have that correct. But what is the value of the loop index l when you fall out of the “for” loop?

In python, you don’t have to wonder what something does. Try it and see:

for ii in range(1,4):
    print(f"ii = {ii}")

print(f"after loop ii = {ii}")