def on_monitor(self, model, dataset, algorithm):
        """
        .. todo::

            WRITEME
        """
        monitor = model.monitor

        if self.first:
            self.first = False
            self.monitor_channel = sharedX(algorithm.scale_step)
            # TODO: make monitor accept channels not associated with any
            # dataset,
            # so this hack won't be necessary
            hack = monitor.channels.values()[0]
            monitor.add_channel('scale_step', hack.graph_input,
                                self.monitor_channel, dataset=hack.dataset,
                                data_specs=hack.data_specs)
        channel = monitor.channels[self.channel]
        v = channel.val_record
        if len(v) == 1:
            return
        latest = v[-1]
        logger.info("Latest {0}: {1}".format(self.channel, latest))
        # Only compare to the previous step, not the best step so far
        # Another extension can be in charge of saving the best parameters ever
        # seen.We want to keep learning as long as we're making progress. We
        # don't want to give up on a step size just because it failed to undo
        # the damage of the bigger one that preceded it in a single epoch
        logger.info("Previous is {0}".format(self.prev))
        cur = algorithm.scale_step
        if latest >= self.prev:
            logger.info("Looks like using {0} "
                        "isn't working out so great for us.".format(cur))
            cur *= self.scale
            if cur < self.giveup_after:
                logger.info("Guess we just have to give up.")
                self.continue_learning = False
                cur = self.giveup_after
            logger.info("Let's see how {0} does.".format(cur))
        elif latest <= self.prev and self.scale_up != 1.:
            logger.info("Looks like we're making progress "
                        "on the validation set, let's try speeding up")
            cur *= self.scale_up
            if self.max_scale > cur:
                cur = self.max_scale
            logger.info("New scale is {0}".format(cur))
        algorithm.scale_step = cur
        self.monitor_channel.set_value(np.cast[config.floatX](cur))
        self.prev = latest
dataset/ETHPy150Open lisa-lab/pylearn2/pylearn2/training_algorithms/bgd.py/StepShrinker.on_monitor/swapped operands of `>`