W2_A2_Ex-8_Model_Test_Assertion Error

I have did my best to figure out but cannot find the cause of problem. Kindly help me to solve it.

Similarly I also faced an assertion problem before in exercise 2 of this week (2) assignment, but still can’t figure both.

Hi @MuhammadHassanKharal ,

For ex2, the problem with fattening of the data possibly due to calling the reshape function incorrectly. The implementation instruction for ex2 should help.

As the reshaped data is used later on in the public text for logistic_regression_model. So the problem that is causing the AssertionError in Ex8 for the model_test() lies with those helper functions that build the model. Did any of those helper functions pass the unit test? if not, then you should go back and get those working first.

I have rechecked that ( reshape function) but still cannot find a way to solve this problem

Hello @MuhammadHassanKharal!

Your figure two shows that you are making a mistake while reshape the training and test data sets.
For exercise 2, a hint is given that:

X_flatten = X.reshape(X.shape[0], -1).T      # X.T is the transpose of X

So, you have to implement this for

# train_set_x_flatten = ...
# test_set_x_flatten = ...

Do you know what is the name for training X and test X? Hint: check a cell which use load_dataset()

Once you cleared the exercise two, maybe you passed exercise 8 as well because Ex. 8 shows your cost is wrong which is depend on the shape of X.

Let me know if you are facing any trouble to implement the reshape function.

Best,
Saif.

Thanks @saifkhanengr
I have tried that and rechecked that thing but still cannot figure out the error. So I just deleted the assert command code and it works well. I don’t understand why does it was giving the error but even though I have built the correct matrix. But the error in exercise 8 still doesn’t work with me well. Can tell me what in particular this error corresponds.

Please show us the error you are getting on exercise 8.

If you have to remove the assertion after the flatten portion, that means your code is still wrong and doesn’t do the flatten the way Saif showed. That will run ok, but you will get lousy training results once you get model to work. The reason is that you are scrambling the data. Here’s a thread which explains why the flatten needs to work the way that Saif showed. Just because the output matrix is the right shape does not mean it is correct.