Here's the image augmentation code:
batch_size = 16
train_datagen = ImageDataGenerator(rescale=1./255, validation_split=0.2)
# test_datagen = ImageDataGenerator(rescale=1./255)
# Use flow from dataframe
train_generator = train_datagen.flow_from_dataframe(
dataframe=train,
directory="train_images",
x_col="id",
y_col=["not_ready", "ready"],
target_size=(300, 300),
batch_size=batch_size,
class_mode="raw",
color_mode="grayscale",
subset="training")
validation_generator = train_datagen.flow_from_dataframe(
dataframe=train,
directory="train_images",
x_col="id",
y_col=["not_ready", "ready"],
target_size=(300, 300),
batch_size=batch_size,
class_mode="raw",
color_mode="grayscale",
subset="validation")
Setup the model:
early_stopping = EarlyStopping(monitor='loss',mode='min',verbose=1,patience=7, restore_best_weights=True)
opt = Adam(learning_rate=0.0002)
model.compile(optimizer=opt, loss='binary_crossentropy', metrics=['accuracy'])
history = model.fit(train_generator,
steps_per_epoch=train_generator.n // batch_size,
epochs=100,
validation_data=validation_generator,
validation_steps=validation_generator.n // batch_size,
callbacks=[early_stopping])
And print the history keys:
print(history.history.keys())
But the results:
dict_keys(['loss', 'accuracy'])
There's no val_loss
and val_accuracy
when I've already had validation_data
. Why is that and how to make them appear?