Logistic_Regression_with_a_Neural_Network_mindset Excercise 8

Hello,
In excercise 8, I’m getting the error below. Appreciate your help

{moderator edit - solution code removed}

ValueError Traceback (most recent call last)
in
1 from public_tests import *
2
----> 3 model_test(model)

~/work/release/W2A2/public_tests.py in model_test(target)
123 y_test = np.array([[0, 1, 0]])
124
→ 125 d = target(X, Y, x_test, y_test, num_iterations=50, learning_rate=0.01)
126
127 assert type(d[‘costs’]) == list, f"Wrong type for d[‘costs’]. {type(d[‘costs’])} != list"

in model(X_train, Y_train, X_test, Y_test, num_iterations, learning_rate, print_cost)
38 b = 0.0
39
—> 40 params, grads, costs = propagate(w, b, X, Y)
41
42 w = params[“w”]

ValueError: not enough values to unpack (expected 3, got 2)

I respond to your this query here.

Thanks,
This is for Excercise 8:
See code

{moderator edit - solution code removed}

See error:

Appreciate your help
Regards
Manny

Hi @Manuel_Trujillo ,

The propagate() function should only return the cost and the gradients. Parameters w and b are updated in the optimize() function. Did your propagate() function pass the unit test? If it didn’t, then it would not work when it is called by other functions.

The code you shown here seemed to be from the model() but is incorrect:

  1. The model() function should be calling the optimize() and not propagate() because there is no parameters updates in propagate()
  2. The sigmoid() is an activation function, it does not do any prediction. The prediction should be done by the predict() function which should have passed its unit test before the starting your work on the model() function.

In addition,
You can call the initialize_with_zeros() function to initialize the parameter w and b, which is better coding practice.

Thanks for your help.
I’m a little lost. I’m including my code. Appreciate your help

{moderator edit - solution code removed}

Thanks.
I’m a little lost. I’m including my code. Appreciate your help.
Regards,
Manny

{moderator edit - solution code removed}

Hi @Manuel_Trujillo ,

I think you need to spend time to understand what your code does. For example, the function initialize_with_zeros() returns w and b, but your model() code only used initialize_with_zeros() for setting w, and had another line of code of setting b. I have already mentioned in my last reply that the sigmoid() function is not for prediction, it is the predict() function to do that.

You will benefit more if you try to understand what your code is doing. The mentors here are very happy to answer your questions and offer assistance, but not writing the code for you. After all, it is your work that earns the marks and certificate. Having the certificate without understanding what you are doing is meaningless.

Thanks Kin
Will do
Appreciate your feedback

Thanks,

Manny

Also please note the Course Honor Code, which was documented in Week 2. We aren’t supposed to share our code in a public way. If the mentors can’t figure out how to help without seeing your code, there are private ways to do that.

Thanks for the reminder
Will do

Thanks,

Manny