Keras: Get True labels (y_test) from ImageDataGenerator or predict_generator

后端 未结 1 1471
一向
一向 2021-02-07 23:37

I am using ImageDataGenerator().flow_from_directory(...) to generate batches of data from directories.

After the model builds successfully I\'d like to get

1条回答
  •  一向
    一向 (楼主)
    2021-02-08 00:00

    You can get the prediction labels by:

     y_pred = numpy.rint(predictions)
    

    and you can get the true labels by:

    y_true = validation_generator.classes
    

    You should set shuffle=False in the validation generator before this.

    Finally, you can print confusion matrix by

    print confusion_matrix(y_true, y_pred)

    0 讨论(0)
提交回复
热议问题