def run(self):
    for epoch in range(self.start_epoch, (self.cfg.n_epoch + 1)):
        if ((epoch % 2) == 0):
            self.lr = lr_decay(self.optimizer, self.lr, self.cfg.lr_decay)
        self.summary.add_scalar('LR', self.lr, epoch)
        average_train_loss = self.train(epoch)
        if (average_train_loss < self.best_accuracy):
            self.best_accuracy = average_train_loss
            self.save(os.path.join(self.cfg.ckpt_dir, 'models', '{}_in{}out{}dctn{}_best_epoch{}_err{:.4f}.pth'.format(self.cfg.exp_name, self.cfg.input_n, self.cfg.output_n, self.cfg.dct_n, epoch, average_train_loss)), self.best_accuracy, average_train_loss)
        self.save(os.path.join(self.cfg.ckpt_dir, 'models', '{}_in{}out{}dctn{}_last.pth'.format(self.cfg.exp_name, self.cfg.input_n, self.cfg.output_n, self.cfg.dct_n)), self.best_accuracy, average_train_loss)
        if ((epoch % 1) == 0):
            loss_l2_test = self.test(epoch)
            print('Epoch: {},  LR: {}, Current err test avg: {}'.format(epoch, self.lr, np.mean(loss_l2_test)))
def run(self):
    for epoch in range(self.start_epoch, (self.cfg.n_epoch + 1)):
        if ((epoch % 2) == 0):
            self.lr = lr_decay(self.optimizer, self.lr, self.cfg.lr_decay)
        self.summary.add_scalar('LR', self.lr, epoch)
        average_train_loss = self.train(epoch)
        if (average_train_loss < self.best_accuracy):
            self.best_accuracy = average_train_loss
            self.save(os.path.join(self.cfg.ckpt_dir, 'models', '{}_in{}out{}dctn{}_best_epoch{}_err{:.4f}.pth'.format(self.cfg.exp_name, self.cfg.input_n, self.cfg.output_n, self.cfg.dct_n, epoch, average_train_loss)), self.best_accuracy, average_train_loss)
        self.save(os.path.join(self.cfg.ckpt_dir, 'models', '{}_in{}out{}dctn{}_last.pth'.format(self.cfg.exp_name, self.cfg.input_n, self.cfg.output_n, self.cfg.dct_n)), self.best_accuracy, average_train_loss)
        if ((epoch % 1) == 0):
            loss_l2_test = self.test(epoch)
            print('Epoch: {},  LR: {}, Current err test avg: {}'.format(epoch, self.lr, np.mean(loss_l2_test)))