问题
I recently upgraded to Keras 2.2.2. The validation accuracy is zero for all training epochs. My training data has data samples in 2 categories i.e., train_data_dir has 2 subfolders. My validation data (i.e., val_data_dir) has data samples in 1 category only but it contains 2 subfolders (one for each category) with no data samples in one of the subfolders. I used to get a meaningful non-zero value for the validation accuracy with an earlier version of Keras. Please help me spot the issue my code (below) and Keras 2.2.2
Below is part of my code:
train_generator = train_datagen.flow_from_directory(
train_data_dir,
target_size = (img_height, img_width),
batch_size = batch_size,
class_mode = "categorical")
validation_generator = val_datagen.flow_from_directory(
val_data_dir,
target_size = (img_height, img_width),
batch_size = batch_size,
class_mode = "categorical",
save_to_dir = 'home/dir')
nb_train_samples = train_generator.n
nb_validation_samples = validation_generator.n
sample_steps = int(nb_train_samples/batch_size)
validation_steps = int(nb_validation_samples/batch_size)
parallel_model.fit_generator(
train_generator,
steps_per_epoch = sample_steps,
epochs = 1,
validation_data = validation_generator,
validation_steps = validation_steps,
callbacks=[early])
来源:https://stackoverflow.com/questions/52197351/validation-accuracy-is-0-with-keras-fit-generator