W1, A2, part3 optimize

Ok, this is an interesting one. The reason that the grader fails does have to do with your clip function. You could argue that the problem is not really a bug in your implementation, but the grader thinks it is. Here’s what happened:

You changed the template code in clip and used a more sophisticated implementation than what they were suggesting. The way your implementation works is that it preserves and clips all entries in the input gradients dictionary, even if they aren’t in the explicit named list of gradients that they gave you in the template code. So if you do it their way and pass in a dictionary that has an extra entry for the key “da_next”, then their version of the code would strip out that entry and the returned dictionary would not contain it. But your version of the code would preserve and clip that entry. Apparently the grader is checking for gradients["da_next"] and expects that not to be found. If it is found, it considers your code incorrect.

I know this sounds weird, but I have confirmed the behavior. Now the question is whether that grader test is legitimate or not. Even if you end up winning that argument, it’s going to take weeks at best to get this resolved and get the grader changed. From a practical standpoint, I suggest you either rewrite your logic to the simpler way or you could even confirm the behavior by deleting that extra key from the dictionary in your clip logic and see that it then passes the grader.

2 Likes