Dw matching error - week 2

Hello everyone, I have been struggling with this particular section of the coding assignment during week 2 i.e Logistic Regression using Neural Network mindset. My issue lies in exercise -8 where i am constantly getting the following error due to which i’m not able to pass the tests.

#---------------------------------------------------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
in
----> 1 model_test(model)

~/work/release/W2A2/public_tests.py in model_test(target)
117 assert type(d[β€˜w’]) == np.ndarray, f"Wrong type for d[β€˜w’]. {type(d[β€˜w’])} != np.ndarray"
118 assert d[β€˜w’].shape == (X.shape[0], 1), f"Wrong shape for d[β€˜w’]. {d[β€˜w’].shape} != {(X.shape[0], 1)}"
β†’ 119 assert np.allclose(d[β€˜w’], expected_output[β€˜w’]), f"Wrong values for d[β€˜w’]. {d[β€˜w’]} != {expected_output[β€˜w’]}"
120
121 assert np.allclose(d[β€˜b’], expected_output[β€˜b’]), f"Wrong values for d[β€˜b’]. {d[β€˜b’]} != {expected_output[β€˜b’]}"

AssertionError: Wrong values for d[β€˜w’]. [[ 2.12603857]
[-1.35973515]
[ 1.58122002]
[ 1.04546508]] != [[ 0.00194946]
[-0.0005046 ]
[ 0.00083111]
[ 0.00143207]]
#---------------------------------------------------------------------------------------------------------------------
Interestingly, the same UDF which is used for this calculation passes the test during exercise 5.

Can anyone please help me out and guide me towards how to rectify it?

Hi @ssmohanty thanks for your message and welcome to the community! Could I ask you check the shape and type of your input parameters first, as the error output seems to suggest there is is something wrong in it.
Regards Stephanus

I am having the same problem.

X_train shape : (4, 3)
Y_train shape : (1, 3)
type of w : <class β€˜numpy.ndarray’>
shape of w: (4, 1)


AssertionError Traceback (most recent call last)
in
----> 1 model_test(model)

~/work/release/W2A2/public_tests.py in model_test(target)
117 assert type(d[β€˜w’]) == np.ndarray, f"Wrong type for d[β€˜w’]. {type(d[β€˜w’])} != np.ndarray"
118 assert d[β€˜w’].shape == (X.shape[0], 1), f"Wrong shape for d[β€˜w’]. {d[β€˜w’].shape} != {(X.shape[0], 1)}"
β†’ 119 assert np.allclose(d[β€˜w’], expected_output[β€˜w’]), f"Wrong values for d[β€˜w’]. {d[β€˜w’]} != {expected_output[β€˜w’]}"
120
121 assert np.allclose(d[β€˜b’], expected_output[β€˜b’]), f"Wrong values for d[β€˜b’]. {d[β€˜b’]} != {expected_output[β€˜b’]}"

AssertionError: Wrong values for d[β€˜w’]. [[ 0.28154433]
[-0.11519574]
[ 0.13142694]
[ 0.20526551]] != [[ 0.00194946]
[-0.0005046 ]
[ 0.00083111]
[ 0.00143207]]

Any guidance please?

@ssmohanty I was having the same problem. But I was able to fix the problem. In my case, I have forgotten to pass the values for default arguments which were different than the default values.

2 Likes

It worked for me as well. I was unmindful about the arguments passed for learning rate. I left it hard-coded basically. Thanks for the tip. Thanks for replying @sjfischer

2 Likes