Skip to content
Advertisement

Confusion Matrix in transfer learning with keras

I was going to draw confusion matrix in my model and I used Transfer learning concept based on Deep Learning model.

Confusion Matrix’s code

JavaScript

Now below the shape of test_labels and Predictions are given,

JavaScript

The above code is perfectly working but I saw error in below. So please concern below code,

JavaScript

and here is the error,

JavaScript

Note: This is value error and I am confused about it I try more and more but I failed. So I need help to solve this error.

Advertisement

Answer

As the error suggests, you have different sample sizes for test_labels and predictions. This may happen when you use batches for prediction which may result in dropping of the last few samples.

One possibility is, you can use:

JavaScript

This may solve the shape mismatch problem (But it is based on the assumption that the last two samples are missing in prediction).

I may be able to provide a more useful answer if you can share the code used for prediction.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement