Week#2 Exercise8

I am having trouble getting past exercise 8, all others past successfully. I understand from previous threads that hardcoding the parameters in the optimize function within the model function, is a common source of error. I have tried everything possible but no success. Below is my error.

AssertionError 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)
127 assert type(d[‘costs’]) == list, f"Wrong type for d[‘costs’]. {type(d[‘costs’])} != list"
128 assert len(d[‘costs’]) == 1, f"Wrong length for d[‘costs’]. {len(d[‘costs’])} != 1"
→ 129 assert np.allclose(d[‘costs’], expected_output[‘costs’]), f"Wrong values for d[‘costs’]. {d[‘costs’]} != {expected_output[‘costs’]}"
130
131 assert type(d[‘w’]) == np.ndarray, f"Wrong type for d[‘w’]. {type(d[‘w’])} != np.ndarray"

AssertionError: Wrong values for d[‘costs’]. [array(0.15900538)] != [array(0.69314718)]

I have also tried removing hardcoded parameters from the default optimize() function below:
def optimize(w, b, X, Y, num_iterations=100, learning_rate=0.009, print_cost=False):

I will appreciate an explanation to get me past this block.

Since you’re getting an error in the final model(), the error could be hiding in any of your functions along the way.

Sadly, passing the tests in the notebook doesn’t prove that any of your functions are perfect.

I have also tried removing hardcoded parameters from the default optimize() function below:
def optimize(w, b, X, Y, num_iterations=100, learning_rate=0.009, print_cost=False):

Messing with any of the code in the notebook outside of the areas that are marked for your modifications, that’s a spectacularly bad idea. It never ends well.