Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- filepath = "model.h5"
- # Declare a checkpoint to save the best version of the model
- checkpoint = ModelCheckpoint(filepath, monitor='val_top_3_accuracy', verbose=1,
- save_best_only=True, mode='max')
- # Reduce the learning rate as the learning stagnates
- reduce_lr = ReduceLROnPlateau(monitor='val_top_3_accuracy', factor=0.5, patience=2,
- verbose=1, mode='max', min_lr=0.00001)
- callbacks_list = [checkpoint, reduce_lr]
- # Fit the model
- history = model.fit_generator(train_batches,
- steps_per_epoch=train_steps,
- class_weight=class_weights,
- validation_data=valid_batches,
- validation_steps=val_steps,
- epochs=10,
- verbose=1,
- callbacks=callbacks_list)
Add Comment
Please, Sign In to add comment