human
I am working on the file "P3_behavioral_cloning/playground.ipynb".
The first task is:
Here is the final 52 param model that we are using for this project.
<div align="left">
  </br>
  <img src="./images/SqueezeNet52.png"><br><br>
</div>

Through some experiments I know that once the loss reach around .03 we have a model that can drive in the simulator so we use a custom early termination callback to stop the training!
Can you write Python program for it?

=====
What is a the Python program you requested?
assistant
#Here is the Python program you requested.

class CustomEarlyStop(Callback):
    """
    Custom Callback that stops the epoch when val_loss reachs 0.3
    This callback assumes you are logging val loss
    """
    def __init__(self, monitor='val_loss'):
        super(CustomEarlyStop, self).__init__()
        self.monitor = monitor
        
   
    def on_epoch_end(self, epoch, logs=None):
        val_loss = logs.get(self.monitor)
        if val_loss <= 0.039:
            print("\nEarly Stop on Epoch {0} with Val_loss {1}\n".format(epoch,val_loss))
            self.model.stop_training = True