def run_epoch(self):
    self.set_model_mode('train')
    losses = MetricMeter()
    batch_time = AverageMeter()
    data_time = AverageMeter()
    self.num_batches = len(self.train_loader_x)
    end = time.time()
    for (self.batch_idx, batch) in enumerate(self.train_loader_x):
        data_time.update((time.time() - end))
        loss_summary = self.forward_backward(batch)
        batch_time.update((time.time() - end))
        losses.update(loss_summary)
        if (((self.batch_idx + 1) % self.cfg.TRAIN.PRINT_FREQ) == 0):
            nb_this_epoch = (self.num_batches - (self.batch_idx + 1))
            nb_future_epochs = ((self.max_epoch - (self.epoch + 1)) * self.num_batches)
            eta_seconds = (batch_time.avg * (nb_this_epoch + nb_future_epochs))
            eta = str(datetime.timedelta(seconds=int(eta_seconds)))
            print('epoch [{0}/{1}][{2}/{3}]\ttime {batch_time.val:.3f} ({batch_time.avg:.3f})\tdata {data_time.val:.3f} ({data_time.avg:.3f})\teta {eta}\t{losses}\tlr {lr}'.format((self.epoch + 1), self.max_epoch, (self.batch_idx + 1), self.num_batches, batch_time=batch_time, data_time=data_time, eta=eta, losses=losses, lr=self.get_current_lr()))
        n_iter = ((self.epoch * self.num_batches) + self.batch_idx)
        for (name, meter) in losses.meters.items():
            self.write_scalar(('train/' + name), meter.avg, n_iter)
        self.write_scalar('train/lr', self.get_current_lr(), n_iter)
        end = time.time()
def run_epoch(self):
    self.set_model_mode('train')
    losses = MetricMeter()
    batch_time = AverageMeter()
    data_time = AverageMeter()
    self.num_batches = len(self.train_loader_x)
    end = time.time()
    for (self.batch_idx, batch) in enumerate(self.train_loader_x):
        data_time.update((time.time() - end))
        loss_summary = self.forward_backward(batch)
        batch_time.update((time.time() - end))
        losses.update(loss_summary)
        if (((self.batch_idx + 1) % self.cfg.TRAIN.PRINT_FREQ) == 0):
            nb_this_epoch = (self.num_batches - (self.batch_idx + 1))
            nb_future_epochs = ((self.max_epoch - (self.epoch + 1)) * self.num_batches)
            eta_seconds = (batch_time.avg * (nb_this_epoch + nb_future_epochs))
            eta = str(datetime.timedelta(seconds=int(eta_seconds)))
            print('epoch [{0}/{1}][{2}/{3}]\ttime {batch_time.val:.3f} ({batch_time.avg:.3f})\tdata {data_time.val:.3f} ({data_time.avg:.3f})\teta {eta}\t{losses}\tlr {lr}'.format((self.epoch + 1), self.max_epoch, (self.batch_idx + 1), self.num_batches, batch_time=batch_time, data_time=data_time, eta=eta, losses=losses, lr=self.get_current_lr()))
        n_iter = ((self.epoch * self.num_batches) + self.batch_idx)
        for (name, meter) in losses.meters.items():
            self.write_scalar(('train/' + name), meter.avg, n_iter)
        self.write_scalar('train/lr', self.get_current_lr(), n_iter)
        end = time.time()