Getting error on the graded assignment for Week 2 Module of Machine Learning Supervised Machine Learning: Regression and Classification.
Please help .
Getting error on the graded assignment for Week 2 Module of Machine Learning Supervised Machine Learning: Regression and Classification.
Please help .
Check if you have any closing parenthesis alone on a line. The grader does not like that.
Hi there is no parenthesis open I checked. This error
Cell #UNQ_C2. Can’t compile the student’s code. Error: SyntaxError(‘invalid character in identifier’, (‘/tmp/student_solution_cells/cell_9.py’, 33, 7, ‘\xa0\xa0\xa0\xa0\xa0\xa0\xa0 f_wb = w*x[i]+b\n’))
Please find below the code:
import numpy as np
import matplotlib.pyplot as plt
from utils import *
import copy
import math
%matplotlib inline
def compute_gradient(x, y, w, b):
# Number of training examples
m = x.shape[0]
# You need to return the following variables correctly
dj_dw = 0
dj_db = 0
for i in range(m):
f_wb = w*x[i]+b
error = f_wb - y[i]
dj_dw_i = (f_wb - y[i]) * x[i]
dj_db_i = f_wb - y[i]
dj_dw /= m
dj_db /= m
return dj_dw, dj_db
Did you download and edit the notebook outside of the Coursera environment?
Or did you change the cell type to Markdown?
I wrote the whole in editor itself, but I got the error. Then wrote the code in Notepad ++, executed the code and then copy pasted it in the editor. There is no setting changed for code or Markdown. I have uploaded the complete code
C1_W2_Linear_Regression.py (27.0 KB)
Using a different editor could have caused the problem.
Hi earlier error fixed now I am getting this error
Code Cell UNQ_C2: Unexpected error (ValueError(‘not enough values to unpack (expected 2, got 1)’)) occurred during function check. We expected function `compute_gradient` to return compute_gradient failed expected [2., [0]]. Please check that this function is defined properly. If you see many functions being marked as incorrect, try to trace back your steps & identify if there is an incorrect function that is being used in other steps. This dependency may be the cause of the errors.
new code:
{mentor edit: code removed}
I should have mentioned this earlier.
Please do not share your code on the forum. That is not allowed by the Code of Conduct.
I have edited your messages to remove the code.