0

I need to get labels from validation dataset for construct the confusion matrix, but I can't get labels with normal order without recreating the dataset with disabled the shuffle. Any idea? Probably, there are any ways to get prediction together with labels? (how is, model.evaluate() works with shuffle)

Dmitry Sokolov
  • 1,303
  • 1
  • 17
  • 29

1 Answers1

1

ok, I found the answer: Getting true labels for keras predictions

for images, labels in val_ds:
    preds = model.predict(images)
    acc_sc = acc(labels, tf.argmax(preds, axis=1))
    print(acc_sc)
    break # or accumulate and average score from all batches

But probably a better way is exist?

Dmitry Sokolov
  • 1,303
  • 1
  • 17
  • 29