Week 4 Assignment 4 Autograder problem


For week 4 assignment 1 I am able to pass all the tests inside the notebook but get this error when submitting: Code Cell UNQ_C3: Unexpected error (UnboundLocalError(“local variable ‘identity’ referenced before assignment”)) occurred during function check. We expected function who_is_it to return compute_layer_style_cost test 1 failed. Please check that this function is defined properly.
If you see many functions being marked as incorrect, try to trace back your steps & identify if there is an incorrect function that is being used in other steps.
This dependency may be the cause of the errors.

However, here is my code passing the tests for that question. Am I guessing this occurs because if the min_dist > dist then identity is not set but it is returned resulting in the error above. So I was able to fix it by adding a identity = None line in the if min_dist > 0.7 code block and that seems to have solved this problem. But just an FYI regarding the autograder

Hey @NeelShah , could you DM the solution you used or this function ? Thanks.

I got the same issue with the grader. I changed min_dist = 1000 instead of 100 and i got the full grade. This feels a bit more logical solution rather than setting the identity separately.

1 Like

thanks for the suggestion!
This method also worked for me. Maybe we can get one of the staff to make a bug report on this? @paulinpaloalto @TMosh

I defined a identity as variable at function scope; then it worked fine for me