I need assistance with Week 3 practice lab: logistic regression. Under section 2.6 Learning parameters using gradient descent, I am to run the codes set by the system but I get the following error: ‘ TypeError: compute_cost() takes 4 positional arguments but 5 were given’
When I run codes in the next section, the system returns the error ‘NameError: name ‘w’ is not defined’ and under Exercise 5 ‘NameError: name ‘compute_cost_reg’ is not defined’. Because of these errors, I cannot complete the assignment. Pls see screenshot. Kindly assist. C1_W3_Logistic Regression error_072025.docx (728.6 KB)
The error says your compute_cost() function is only defined to take 4 arguments when it should take 5. Make sure you did not change the definition for compute_cost() to remove the last argument. In general, you should only change the code between ### START CODE HERE ### and ### END CODE HERE ###.
This is what the beginning of your compute_cost function should look like:
As far as the other error you are seeing later, with ‘w’ not being defined makes sense, because ‘w’ is defined in the cell where you got the error calling compute_cost(). Since that cell did not run successfully, it didn’t get to the point of defining ‘w’. Once you fix the compute_cost() parameter and re-run everything successfully, that problem should go away.