4

So I've trained a CNN using the keras library, specifically using the .flow_from_directory() method, where my images are stored in training_set, validation_set and test_set folders, but I can't find a way to test the test_set folder.

Do I have to create a .csv file?

I've tried using model.evaluate(), but that doesn't seem to work using images stored in classification folders. Thanks in advance for the helps!

Amila
  • 5,195
  • 1
  • 27
  • 46
gabriel
  • 43
  • 4

1 Answers1

6

You can use evaluate_generator function. You can use the same flow_from_directory to provide the generator as the first argument to this function.

test_datagen = ImageDataGenerator(...)
test_generator = test_datagen.flow_from_directory(...)
model.evaluate_generator(test_generator, ...)
Amila
  • 5,195
  • 1
  • 27
  • 46
  • @gabriel, accepting / upvoting answer is appreciated if it helped you. – Amila Sep 28 '18 at 19:37
  • 1
    Done. Stack won't show that I upvoted you yet (not enough rep), but it's there. – gabriel Sep 28 '18 at 23:25
  • evaluate_generator is deprecated, you should use evaluate method instead. Here is a good example about its usage, https://stackoverflow.com/a/63950899/2234161 – Memin Nov 14 '22 at 13:39