Key Error C2 W2 optimization techniques lab

I’m unable to resolve this error
@TMosh Pls help me with this so that I can proceed with the assignment without hassle

1 Like

In general it’s not a great idea to address your Forum posts to a specific individual. There are lots of other mentors available, and maybe in a more timely manner or with better experience in a specific course.

If you’re getting an error for W3, that most likely means there’s an error in either your ‘l’ or ‘i’ values.

1 Like

Why are you adding 1 to l there? Here is the template code they gave you:

for l in range(1, L + 1):
        # (approx. 2 lines)
        # parameters["W" + str(l)] =  
        # parameters["b" + str(l)] = 

So they have clearly already taken into account the fact that indexing in python is zero-based. You could also have figured this out by looking at the test case code to see how many layers were in the test case. That is in the file You would see that there are only 2 layers, so that it doesn’t make sense to reference W3.

Debugging is part of the job of being a programmer: you can’t just throw up your hands when you get an error message. You need to develop the skills for figuring out where your mistakes are. You’re not done until the code works, right? Once you get out into the real world, you won’t have folks like Tom and me to help you out, so part of what we are learning here is debugging skills if you’re not already an experienced programmer.

OK sir I’ll make changes to my code and make sure it is in accordance with the given parameters! Thanks for the heads up !

1 Like