I've been working with ImageDataGenerator and flow_from_directory in many examples:
val_gen = ImageDataGenerator()
val_imageflow = val_gen.flow_from_directory(validation_path, ...)
and then use it in fit funtion for training and validation data:
hist = model.fit(..., validation_data=val_imageflow,...)
But now I need to use validation_data in shape (x_data, y_data), like for case
hist = model.fit(..., validation_data=(x_data, y_data),...)
The reason is that I want to use callback in my fine-tuned CNN on end of every epoch to show correct classification for each class. Unfortunately I cannot get the point how to get generator val_imageflow into tuple. I'd tried to run following code, but it consumed all RAM very quickly and processing was interrupted (I probably do something wrong)
x_data = []
y_data = []
while True:
try:
n = next(val_imageflow)
x_data.append(n[0])
y_data.append(n[1])
except StopIteration:
break
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…