C1_W3_Logistic_Regression showing error

one of the cell is not running and shows this error:

TypeError Traceback (most recent call last)
in
13 w,b, J_history,_ = gradient_descent(X_mapped, y_train, initial_w, initial_b,
14 compute_cost_reg, compute_gradient_reg,
—> 15 alpha, iterations, lambda_)

in gradient_descent(X, y, w_in, b_in, cost_function, gradient_function, alpha, num_iters, lambda_)
46 if i% math.ceil(num_iters/10) == 0 or i == (num_iters-1):
47 w_history.append(w_in)
—> 48 print(f"Iteration {i:4}: Cost {float(J_history[-1]):8.2f} ")
49
50 return w_in, b_in, J_history, w_history #return w and J,w history for graphing

TypeError: only size-1 arrays can be converted to Python scalars

this code cell is already filled and is uneditable. Please help.

Link to the notebook

Hi @Farhan_Ali1

Make sure that the previous cells are working fine, because, this code snippet uses previously implemented cells that are written by you.

Hope it helps! Feel free to ask if you need further assistance.

This error message means your gradient_descent() function has an error, because the data it returns for J_history has the wrong structure.

Also, posting a link to your notebook is 1) not useful, because we cannot log into your account, so the file is not available, and 2) sharing your code would violate the Code of Conduct.

I have been stuck for three days now on 2.6 in Week three. I keep get the error in Graded Function Compute cost:
File “”, line 8
Args:
^
SyntaxError: invalid character in identifier

I have tried deleting white spaces, re-writing lines from the beginning, etc. Am I’m using the wrong browser? Wrong settings in my Jupyter notebook?

Syntax errors are reported after they are detected, so the issue is somewhere prior to line 8 in the notebook file.

Update for those finding this thread later:

The notebook had several issues such as modifications outside of the marked areas, some functions had been duplicated, cells were added that modified the provided data set, and some errors in the code caused incorrect calculations.

Hello,
I’m having a problem: every time I try to submit the logistic regression lab week three, I keep getting 0% and an error. This is the error message I receive:

Cell #3. Can’t compile the student’s code. Error: OSError(‘data/ex2data1.txt not found.’)

I’ve been trying for a long time but it’s not working. I’ve completed the whole course — this is the last task, but I can’t submit it.

@Lojana
The most likely cause for this issue is that something in your notebook has been modified (i.e. a cell was edited, added, moved, or deleted), such that the grader is looking for a file that it cannot find.

This type of issue can be very difficult to repair.

I recommend you get a new copy of the notebook and start over.

  • Use the File menu and rename your notebook.
  • Use the Lab Help tool and then “Get latest version”.
  • Use the File → Open menu, and open the new copy of the notebook.
  • Use “Kernel → Restart & clear all output”, so that you have an empty workspace.

The “Lab Help” tool is the question-mark inside a circle, in the upper right corner of your browser.

Be very careful to only modify the notebook in the areas marked “START CODE HERE”.

1 Like

Every time I try to open a new notebook, it doesn’t work — it keeps opening the old one with all the changes saved, and it doesn’t start a new one.

You need to rename or delete your original notebook first.

1 Like

“Get latest version” will not update a file that already exists. It only replaces missing files.

The name of the tool is really misleading, but it’s a Coursera tool that DLAI can’t modify.

Thank you for your help.
I finally completed the course​:star_struck:

1 Like

That’s great news, congratulations!