Callbacks are functions that are called during the training process in Keras, which can be used to keep track of important metrics, apply regularization, or alter the learning rate. These functions are called at certain stages of the training process and can be used to monitor and even modify the behaviour of the training algorithm.
Commonly used callbacks include:
1. ModelCheckpoint: This callback saves the model after every epoch, which is useful in case the training process is interrupted or there is a power failure during the training process. It saves the best weights of the model, and the saved model can be loaded and used for further training, for deploying or for prediction.
2. EarlyStopping: This callback monitors a specified metric and stops the training process when the monitored metric doesn’t improve for a specific number of epochs. This is useful when you want to avoid overfitting the data and stop training early when the model is not improving its validation performance.
3. ReduceLROnPlateau: This callback reduces the learning rate when the validation metric doesn’t improve for a specified number of epochs. This is useful for fine-tuning the model, as it allows for smaller and smaller steps to be taken towards the optimal model weights, which can help avoid over-shooting the minimum.
4. TensorBoard: This callback logs the training process and can be used to visualize the metrics in TensorBoard, an interactive visualization tool offered by TensorFlow. This allows you to monitor the progress of your model during training and helps you to identify the weaknesses in your model.
5. CSVLogger: This callback logs the loss and evaluation metrics into a CSV file, which can be easily visualized using Excel, LibreOffice Calc or other spreadsheet software.
Overall, callbacks are very useful in Keras, allowing you to monitor the training process, configure early stopping, track metrics and optimize hyperparameters automatically.