Problems doing Programming Assignment: Week 2 practice lab: Linear regression:
-
First of all, I don’t seem to be able to touch (add, change, delete) the codes in any cell of the assignment. All I could do is place the cursor in the cell and click RUN. That is how I did every exercise up to this point. Did I miss something?
-
After executing cell [8] of the assignment, the program returns Cost at initial w: 0.000, which is different from the code:
initial_w = 2 (in line 1). It also returns AssertionError:
AssertionError Traceback (most recent call last)
in
9 # Public tests
10 from public_tests import *
—> 11 compute_cost_test(compute_cost)
~/work/public_tests.py in compute_cost_test(target)
17 initial_b = 1.0
18 cost = target(x, y, initial_w, initial_b)
—> 19 assert cost == 2, f"Case 2: Cost must be 2 but got {cost}"
20
21 # print(“Using X with shape (5, 1)”)
AssertionError: Case 2: Cost must be 2 but got 0
Expected Output:
Cost at initial w: 75.203
Please help!
check your codes. incorrect initial codes. you should get 0 value but got 2, that means your implementation is incorrect
Thank! I did not modify the codes. They came with the Lab. How do I go into the cell and making changes to the codes?
Yes the codes which came with the lab are correct.
the code error you are getting is for UNQ-C1 right?
Hello Sam,
The below code was given
You need to return this variable correctly
total_cost = 0
But first you need to write
Variable to keep track of sum of cost from each example
So here initial cost should be 0
Then under the loop over training examples where first you will predict the f_wb for ith example and then cost gets associated with the ith example.
after this the initial cost which you created for each example needs to be added to the sum of cost for each example.All these under the loop
At the end total cost is calculated using the cost sum you calculated from the above codes which is outside the loop.
Regards
DP
Am I supposed to be able to go and modify the code?
Hello Sam_Tung,
You do not need to modify any codes outside of ###START AND END CODE HERE###
Assignments for this specialisation are actually very simple, only the implementation part needs to be done correctly.
Read instructions given above and hints given below which will help you if you get stuck.
Let me know once your issue is resolved. Or ask if still unable to understand.
Regards
DP
Thank again! Let me study your suggestion and try again.
Goodbye!