def _fine_tune(self):
    ' Fine Tune\n\n        Fine tune the final model training.\n\n        '
    model = self._build_final_model(load_top_weights=True)
    self._freeze_layers(model, 18)
    model.compile(loss='binary_crossentropy', optimizer=Adam(lr=0.0001), metrics=['binary_accuracy'])
    train_gen = self._load_generator(self._features['train']['dir'], batch_size=self._batch_size_fine, class_mode='binary', augmentation=True)
    valid_gen = self._load_generator(self._features['valid']['dir'], batch_size=self._batch_size_fine, class_mode='binary')
    callbacks = []
    callbacks.append(ModelCheckpoint('{}.h5'.format(self._fine_tune_file), monitor='val_loss', verbose=self._verbose, save_best_only=True, save_weights_only=True, mode='auto', period=1))
    callbacks.append(EarlyStopping(monitor='val_loss', min_delta=0.001, patience=10, verbose=self._verbose))
    callbacks.append(ReduceLROnPlateau(monitor='val_loss', factor=0.5, patience=5, min_delta=0.001, cooldown=2, verbose=self._verbose))
    model.fit_generator(train_gen, steps_per_epoch=train_gen.steps, epochs=self._epochs_fine, callbacks=callbacks, validation_data=valid_gen, validation_steps=valid_gen.steps, verbose=self._verbose)
    self._freeze_layers(model, 19)
    model.layers[17].trainable = True
    model.compile(loss='binary_crossentropy', optimizer=SGD(lr=0.0001), metrics=['binary_accuracy'])
    model.fit_generator(train_gen, steps_per_epoch=train_gen.steps, epochs=self._epochs_fine, callbacks=callbacks, validation_data=valid_gen, validation_steps=valid_gen.steps, verbose=self._verbose)
    model.save_weights('{}.h5'.format(self._final_model_file))
Fine Tune

Fine tune the final model training.
def _fine_tune(self):
    ' Fine Tune\n\n        Fine tune the final model training.\n\n        '
    model = self._build_final_model(load_top_weights=True)
    self._freeze_layers(model, 18)
    model.compile(loss='binary_crossentropy', optimizer=Adam(lr=0.0001), metrics=['binary_accuracy'])
    train_gen = self._load_generator(self._features['train']['dir'], batch_size=self._batch_size_fine, class_mode='binary', augmentation=True)
    valid_gen = self._load_generator(self._features['valid']['dir'], batch_size=self._batch_size_fine, class_mode='binary')
    callbacks = []
    callbacks.append(ModelCheckpoint('{}.h5'.format(self._fine_tune_file), monitor='val_loss', verbose=self._verbose, save_best_only=True, save_weights_only=True, mode='auto', period=1))
    callbacks.append(EarlyStopping(monitor='val_loss', min_delta=0.001, patience=10, verbose=self._verbose))
    callbacks.append(ReduceLROnPlateau(monitor='val_loss', factor=0.5, patience=5, min_delta=0.001, cooldown=2, verbose=self._verbose))
    model.fit_generator(train_gen, steps_per_epoch=train_gen.steps, epochs=self._epochs_fine, callbacks=callbacks, validation_data=valid_gen, validation_steps=valid_gen.steps, verbose=self._verbose)
    self._freeze_layers(model, 19)
    model.layers[17].trainable = True
    model.compile(loss='binary_crossentropy', optimizer=SGD(lr=0.0001), metrics=['binary_accuracy'])
    model.fit_generator(train_gen, steps_per_epoch=train_gen.steps, epochs=self._epochs_fine, callbacks=callbacks, validation_data=valid_gen, validation_steps=valid_gen.steps, verbose=self._verbose)
    model.save_weights('{}.h5'.format(self._final_model_file))