'Returns True or False depending on whether the optimization should
stop or not. The optimization should stop if it has run for a number
of epochs superior to the patience without any improvement.
Parameters
model : Model
The model used in the experiment and from which the monitor used
in the termination criterion will be extracted.
Returns
bool
True or False, indicating if the optimization should stop or not.'

def __call__(self, model):

    monitor = model.monitor
    if (self._channel_name is None):
        if (len(monitor.channels) != 1):
            raise ValueError('Only    single-channel    monitors    are    supported    for    channel_name    ==    None')
        v = monitor.channels.values()[0].val_record
    else:
        v = monitor.channels[self._channel_name].val_record
    if (v[(-1)] < (self.best_value * (1.0 - self.prop_decrease))):
        self.patience = max(self.patience, (len(v) * self.patience_increase))
        self.best_value = v[(-1)]
    return (len(v) < self.patience)
