C3W3 Assignment function classify -> unmatch expected output

Hi, Function confusion matrix is wrong due to the shape of y_pred and y_test is not match.

I tried to edit my code. Currently, I can the result out but my answer not match the expected answer.

Hi @skinx.learning

The shape of y_test is [10240]. However, the shape of pred is [10240, 256] , indicating that it is a 2D array with 10240 rows and 256 columns, which must have the same shape as y_test.

To resolve this issue, you need to ensure that y_pred and y_test (they should typically be integer values representing class labels) have compatible shapes. Then, verify that both arrays have the same dimensions.

Try printing the shapes of y_test and pred before passing them to tf.math.confusion_matrix so you can debug your code.

Hi, thanks for your suggestion. I check the shape both of y_test and y_pred have the same shape already. Now, I calculate for the accuracy and confusion matrix but the value doesnt match with expected output result.

I don’t have access to the course notebooks. However, there is an issue with either the data preprocessing, model architecture, or training process.

Before making significant changes, make sure that the previous codes are running as expected. Then, consider tweaking the model architecture by adding more layers or adjusting the number of units.

Ensure that you follow all the instructions provided and don’t forget to monitor the training process to identify any potential issues.

The previous cell are all test passed for triplet loss, train model and model structure.

Hi @skinx.learning

Looking at the error message it is visible that you use pred variable instead of y_pred

Cheers

P.S. there are multiple previous posts related to the classify function (link1, link2, link3 and others) that could offer you hints to solve your problem.