Hello, I am not quite sure what I am doing wrong in my exercise, but computing the cost seems to be off somewhere:
# UNQ_C2
# GRADED FUNCTION: compute_cost
def compute_cost(X, y, w, b, *argv):
# moderator edit: code removed
Hello, I am not quite sure what I am doing wrong in my exercise, but computing the cost seems to be off somewhere:
# UNQ_C2
# GRADED FUNCTION: compute_cost
def compute_cost(X, y, w, b, *argv):
# moderator edit: code removed
Please do not post your code on the forum. That’s not allowed by the course Code of Conduct.
If a mentor needs to see your code, we’ll contact you with instructions.
You can post any error messages or asserts that you get when you run the tests in the notebook. A screen capture image is the best way to do this.
I have edited your message to remove the code.
Here is a hint: If you’re going to use nested for-loops, so that you have complete index values for 'w and ‘X’, then you do not need to use the numpy dot function. np.dot() is intended for vector products.
When you just have scalars, you can use regular old multiplication.
Or, if you want to use np.dot(), you don’t need any for-loops at all.
The only thing that the tests check is your results - not the method you use to get them.
Hello Iziren,
Please do the corrections to your grader cell based on the below image.
Also please follow Code of Conduct as mentioned by the supermentor @TMosh
Thank you Tom for editing the post and removing the codes from post.
Regards
DP
Hello, I am getting the following AssertionError:
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
<ipython-input-29-9c05a6dc79a2> in <module>
8
9 # UNIT TESTS
---> 10 compute_cost_test(compute_cost)
~/work/public_tests.py in compute_cost_test(target)
24 b = 0
25 result = target(X, y, w, b)
---> 26 assert np.isclose(result, 2.15510667), f"Wrong output. Expected: {2.15510667} got: {result}"
27
28 X = np.random.randn(4, 3)
AssertionError: Wrong output. Expected: 2.15510667 got: 1.7461071120044385
This means your code does not compute the correct values.
Yes, I am aware, but I am not sure where in my code I am going wrong because I am using the correct formula.
If you are using the correct formula, maybe your implementation is incorrect.
That is exactly what I am trying to figure out
Where in my implementation am I going wrong? I feel as if the debugging tools on Juypter Notebook aren’t great. I can not create break points and step through the code. Or maybe there is a way to do so?
You can’t set any breakpoints.
The best you can do is to add print() statements to your code so you can get intermediate results, and compare them with your own hand-calculated values.
The only problem with that is that I would have to pay attention to my calculations for a sample size of 100. I don’t think this is ideal on pen and paper
Check your private messages for instructions.
z_wb_ij = make sure you have recalled with the right codes for this line.
Check the hint section below to get the right code.