The failure occurred when I ran file C1M1_Assignment.ipynb in your course Deep Learning AI called PyTorch: Fundamentals. This is Module 1 of 4. I believe that here is a bug in this code. Kindly run this file for yourself. See if your reference version runs without error. My numerous attempts over more than 10 days have all failed. If it runs without error, please send me a copy of that file. If your run fails like mine did–as reported–then you have confirmed that this course material is defective. I would very much appreciate a human taking action here. Your AI generated robotic responses just ask the same canned questions without doing anything or solving anything. I followed their suggestions to no avail.
Can you provide a few details about where you believe there is an error? Screen capture images of any error messages would be very helpful.
Please realize that no-one else can look directly at your assignment files. So as Tom says, you’ve given us nothing concrete that we can evaluate. I was able to complete that assignment without encountering any issues.
Please give us some concrete evidence of the issue that you are seeing. Please don’t show solution source code here on a public thread, but showing the output of the failing test case would be one place to start. If we need to actually see your code, there are non-public ways to do that, but let’s start with the output.
Also note that you’ve filed this question in a generic category (AI Discussions). For questions that are course specific, it’s a better idea to file them under the category of the actual course. That gives you a better chance of getting a timely and relevant response. I will use the little “edit pencil” on the title to move this to the appropriate category. I marked this as using the DLAI LP, but please let us know if you are taking this on Coursera instead.
the coding "rush_hour_feature fails. The failure message that I am concerned about is the 3rd to 7th lines from the bottom, in the text below: the Expected:torch.Size([4[) was 5 when 4 was expected. You can see that the relevant tensors printed are all of Size[5] and each one is correct. My conclusion is that the coding of “rush_hour_feature” is at fault. I am new to reporting an issue. I do not see any option to attach a screen shot. Thanks for reviewing this issue.
{
“cell_type”: “code”,
“execution_count”: 10,
“id”: “c060838e-93e5-4876-a9a9-69218c00cfbf”,
“metadata”: {
“deletable”: false,
“editable”: false
},
“outputs”: [
{
“name”: “stdout”,
“output_type”: “stream”,
“text”: [
“sample_hours= tensor([ 8.2000, 16.8000, 8.0200, 16.0700, 13.4700])\n”,
“sample_weekends= tensor([0., 1., 1., 0., 0.])\n”,
“Is morning rush?: [ True False True False False]\n”,
“Is evening rush?: [False True False True False]\n”,
“Is weekday?: [ True False False True True]\n”,
“is_rush_hour_mask= tensor([1., 0., 0., 1., 0.])\n”,
“\u001b[91mFailed 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.\n”,
“Expected: torch.Size([4])\n”,
“Got: torch.Size([5])\n”,
“\n”,
“\n”
]
Hello @ArneO,
The cell id c060838e-93e5-4876-a9a9-69218c00cfbf you provided indicates that the problem was with the following cell:

In your output, we can find the following lines:

which were the exact data used by the cell directly above:
The two cells here are using two different sets of data, and since they saw the same set in your case, it is likely that you did not use the proper variable names for your exercise:
We should stick to the variable names in the argument list of the function, so that the function can process different content passed to these variable names.
Cheers,
Raymond
Raymond has diagnosed the problem (directly referencing global variables in the body of your function), but it’s also worth addressing your other question about how to attach a screenshot. How you take a screenshot is dependent on your particular OS, but once you have it, simply use the little “Up Arrow” tool in the edit toolbar as highlighted in this screenshot:
What you have “copy/pasted” in your reply above is the raw JSON text of the notebook. I’m not sure how to even do that without downloading the ipynb file and then opening it with a text editor.
Hi @ArneO,
To build on the previous points: a good rule of thumb is that matching the expected output does not mean your implementation is correct overall, as it only verifies a single specific case.
There is a fundamental difference between the Expected Output cell and the Test Cell. It is important to understand that these two cells are entirely independent and are not related in how they evaluate your code.
-
The Expected Output cell, which in this case is:
rush_hour_for_sample = rush_hour_feature(sample_hours, sample_weekends) print(f"Sample Hours: {sample_hours.numpy()}") print(f"Sample Weekends: {sample_weekends.numpy()}") print(f"Is Rush Hour?: {rush_hour_for_sample.numpy()}")checks if your implementation produces the correct answer for one specific set of input values. It serves as a soft check to show explicit output and help you identify obvious errors.
-
The Test Cell cell, which in this case is:
# Test your code! unittests.exercise_1(rush_hour_feature)verifies if your logic holds true for a wide range of possible inputs. It is a much more thorough check designed to ensure your implementation is robust.
Think of it like building a function to calculate the area of a rectangle. If the input length is 10 and the width is 10, the expected output is 100. If your function returns 100, it passes that specific check.
However, if the function was implemented like this:
def calculate_area(length, width):
area = length * width
return 100
The implementation is fundamentally flawed because it will always return 100 regardless of the input values. Just because it passes the expected value for one case, it does not mean it is a universal solution.
While your code might work for the sample provided in the notebook, the unit tests are finding a flaw in the underlying logic. This generally happens when the function parameters are not used as instructed. Common mistakes include referencing global variables or using hard coded values, both of which prevent the function from being a correct solution.
Please revise your implementation based on the instructions from Raymond and the test should pass.
Best,
Mubsi


