Problem in C1M1 Assignment

I am getting an error as shown below:

“Failed test case: is_rush_hour_mask returned from rush_hour_feature has wrong shape. Follow the exercise instructions to make sure you are correctly implementing all of the conditions and operations.
Expected: torch.Size([4])
Got: torch.Size([5])“

Couple of points:

  • I have only modified code in the area between “start code here” and “end code here”
  • The modified code matches the “additional code hints” mentioned.

Screenshot is attached:

{moderator edit - solution code removed}

@Shiv_Bhagavatula

you are using incorrect variable recall.
remember each grade function has arguments assignment for variable to be used.

Check again in instructions under exercise heading, and look. at the arguments which variable you need to recall.

Also posting codes is gross violation of code of conduct, remove the image. if mentor wants to look at your codes they will ask to send by personal DM

Another way to state the point that @Deepti_Prasad has made is to say that you are making the mistake of referencing global variables from the body of your function. That means that your code is not general: it will only pass one particular test case and then fails a different one that passes different global variables as the parameters to your function.

This is a valuable lesson for all the assignments here: we always want to write general code that will work correctly with any valid inputs. Please be sure to only reference the formal parameters of your function and other local variables within the body of your functions and not to hard-code any assumptions about the dimensions of the objects unless they explicitly tell you to do that in the instructions.

To be more precise the below screenshot has the (local) variable names for all 3 conditions you were suppose to write, and it is not sample hours or sample weekend.

Thanks for the response. It now works.

Apologies for posting the code.

Regards,

Shiv