# Week 2 practice lab - Linear regression, error on grading

**URL:** <https://community.deeplearning.ai/t/week-2-practice-lab-linear-regression-error-on-grading/835405>\
**Category:** Supervised ML: Regression and Classification\
**Tags:** week-module-2\
**Created:** [June 18, 2025, 4:25am UTC](https://community.deeplearning.ai/t/week-2-practice-lab-linear-regression-error-on-grading/835405 "2025-06-18T04:25:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lukex](https://avatars.discourse-cdn.com/v4/letter/l/47e85d/32.png) [@Lukex](https://community.deeplearning.ai/u/Lukex)\
**Post date:** [June 18, 2025, 4:25am UTC](https://community.deeplearning.ai/t/week-2-practice-lab-linear-regression-error-on-grading/835405/1 "2025-06-18T04:25:24Z")

</div>

C1\_W2\_Linear\_Regression  
for the Week 2 practice lab: Linear regression, I finished my implemention of both functions and submitted for grading, got error message for function compute\_cost only, but I tested it I get the expected result as shown in following test code cell. failed with grading got only 50% pass. I did not see any issue with my code.

**error message:**  
Code Cell UNQ\_C1: Unexpected error (IndexError(‘index 3 is out of bounds for axis 0 with size 3’)) occurred during function check. We expected function `compute_cost` to return cost for perfect prediction must be 0. Please check that this function is defined properly.

Much appreciated for support this issue so I can pass the weeks grading.  
Best regards, Luke

---

<div class="post-metadata">

**Author:** ![gent.spah](https://sea1.discourse-cdn.com/dlai/user_avatar/community.deeplearning.ai/gent.spah/32/136423_2.png) [@gent.spah](https://community.deeplearning.ai/u/gent.spah)\
**Post date:** [June 18, 2025, 9:04am UTC](https://community.deeplearning.ai/t/week-2-practice-lab-linear-regression-error-on-grading/835405/2 "2025-06-18T09:04:09Z")

</div>

It seems the grader is not passing all the tests on your UNQ\_C1, keep in mind that the grader has a bunch of different tests than those run in the script. Apparently from this error I can think that you are accessing an element beyond a array’s size!

---

<div class="post-metadata">

**Author:** ![Lukex](https://avatars.discourse-cdn.com/v4/letter/l/47e85d/32.png) [@Lukex](https://community.deeplearning.ai/u/Lukex)\
**Post date:** [June 19, 2025, 2:43pm UTC](https://community.deeplearning.ai/t/week-2-practice-lab-linear-regression-error-on-grading/835405/3 "2025-06-19T14:43:05Z")

</div>

Thanks a lot Gent, Tom helped to find one bug regarding my careless reference 2 variables in the function.
