Course1 Week2 assignment : Failing in model

I am getting below error while running model_test(model).
ValueError: shapes (1,3) and (4,3) not aligned: 3 (dim 1) != 4 (dim 0)

I have not used any hardcoded matrix dimensions. How to fix this?



Most probably the error is due to an incorrect shape of w.

Maybe you could try to debug the error by checking the shape of w versus the shape of X_train by adding some print statements inside the model function. And then checking the shape of w in other functions where its shape could have been wrongly defined because that error is not happening in the model function but in another one.

That’s correct. Further debugged and found passing incorrect value. Thakns.

I am getting following errors in model_test(model)
—> assert type(d[‘costs’]) == list, f"Wrong type for d[‘costs’]. {type(d[‘costs’])} != list"
IndexError: only integers, slices (:), ellipsis (...), numpy.newaxis (None) and integer or boolean arrays are valid indices
w shape is (4,1)

Just confirming! we are using X_train and Y_train for optimize function right?

I would check what’s the type of costs and the type of d['costs'] whenever it is used. That should be a list as indicated by the error code.

Please review, what you are assigning to that variable and also in the d dictionary because it seems that you have assigned something which is not a list that’s why the assert is failing.

Sure. Thank you for the suggestion.