def main(self):
        print_mem('start')
        self.state['gotNaN'] = 0
        self.start_time = time.time()
        self.batch_start_time = time.time()
        self.step = 0
        self.save_iter = 0
        self.save()
        if self.channel is not None:
            self.channel.save()
        self.save_time = time.time()
        last_cost = 1.
        start_time = time.time()
        self.start_time = start_time
        self.state['clr'] = self.state['lr']

        while (self.step < self.state['loopIters'] and
               last_cost > .1*self.state['minerr'] and
               (time.time() - start_time)/60. < self.state['timeStop'] and
               self.state['lr'] > self.state['minlr']):
            if (time.time() - self.save_time)/60. > self.state['saveFreq']:
                self.save()
                if self.channel is not None:
                    self.channel.save()
                self.save_time = time.time()
            st = time.time()
            try:
                rvals = self.algo()
                self.state['traincost'] = float(rvals['cost'])
                self.state['step'] = self.step
                last_cost = rvals['cost']
                for name in rvals.keys():
                    pos = self.step // self.state['trainFreq']
                    self.timings[name][pos] = float(numpy.array(rvals[name]))

                if (numpy.isinf(rvals['cost']) or
                   numpy.isnan(rvals['cost'])) and\
                   self.state['on_nan'] == 'raise':
                    self.state['gotNaN'] = 1
                    self.save()
                    if self.channel:
                        self.channel.save()
                    print 'Got NaN while training'
                    last_cost = 0
                if self.valid_data is not None and\
                   self.step % self.state['validFreq'] == 0 and\
                   self.step > 1:
                    valcost = self.validate()
                    if valcost > self.old_cost * self.state['cost_threshold']:
                        self.patience -= 1
                        if 'lr_start' in self.state and\
                           self.state['lr_start'] == 'on_error':
                                self.state['lr_start'] = self.step
                    elif valcost < self.old_cost:
                        self.patience = self.state['patience']
                        self.old_cost = valcost

                    if self.state['divide_lr'] and \
                       self.patience < 1:
                        # Divide lr by 2
                        self.algo.lr = self.algo.lr / self.state['divide_lr']
                        bparams = dict(self.model.best_params)
                        self.patience = self.state['patience']
                        for p in self.model.params:
                            p.set_value(bparams[p.name])

                if self.state['hookFreq'] is not 0 and \
                   self.step % self.state['hookFreq'] == 0 and \
                   self.hooks:
                    [fn() for fn in self.hooks]
                if self.reset > 0 and self.step > 1 and \
                   self.step % self.reset == 0:
                    print 'Resetting the data iterator'
                    self.train_data.reset()

                self.step += 1
            except:
                self.state['wholetime'] = float(time.time() - start_time)
                self.save()
                if self.channel:
                    self.channel.save()

                last_cost = 0
                print 'Error in running algo (lr issue)'
                print 'Took', (time.time() - start_time)/60., 'min'
                raise

        self.state['wholetime'] = float(time.time() - start_time)
        if self.valid_data is not None:
            self.validate()
        self.save()
        if self.channel:
            self.channel.save()
        print 'Took', (time.time() - start_time)/60., 'min'
dataset/ETHPy150Open pascanur/GroundHog/groundhog/mainLoop.py/MainLoop.main/operator `>` -> `is not`