train_datagen = ImageDataGenerator(rescale=1./255)
test_datagen = ImageDataGenerator(rescale=1./255)
train_generator = train_datagen.flow_from_directory(
'dataset/train',
target_size=(32, 32),
batch_size = 478,
class_mode='binary')
validation_generator = test_datagen.flow_from_directory(
'dataset/valid',
target_size=(32, 32),
batch_size = 60,
class_mode='binary')
model = Sequential()
model.add(layers.Conv2D(filters=6, kernel_size=(3, 3), activation='relu', input_shape=(32,32,3)))
model.add(layers.AveragePooling2D())
model.add(layers.Conv2D(filters=16, kernel_size=(3, 3), activation='relu'))
model.add(layers.AveragePooling2D())
model.add(layers.Flatten())
model.add(layers.Dense(units=120, activation='relu'))
model.add(layers.Dense(units=84, activation='relu'))
model.add(layers.Dense(units=2, activation = 'sigmoid'))
model.compile( loss = 'categorical_crossentropy',optimizer = 'adam', metrics = ['accuracy'])
model.summary()
model.fit_generator(
train_generator,
steps_per_epoch=478,
epochs=100,
validation_data=validation_generator,
validation_steps=60)