def pretrain_main_model(self, max_epoch):
    for epoch in range(max_epoch):
        print((('###### Epoch ' + str(epoch)) + ' ######'))
        tot_correct = 0
        tot_not_na_correct = 0
        tot = 0
        tot_not_na = 0
        i = 0
        time_sum = 0
        for (i, batch_data) in enumerate(self.train_data_loader):
            time_start = time.time()
            (iter_loss, iter_logit, _train_op) = self.one_step(self.sess, self.model, batch_data, [self.model.loss(), self.model.train_logit(), self.train_op])
            time_end = time.time()
            t = (time_end - time_start)
            time_sum += t
            iter_output = iter_logit.argmax((- 1))
            iter_label = batch_data['rel']
            iter_correct = (iter_output == iter_label).sum()
            iter_not_na_correct = np.logical_and((iter_output == iter_label), (iter_label != 0)).sum()
            tot_correct += iter_correct
            tot_not_na_correct += iter_not_na_correct
            tot += iter_label.shape[0]
            tot_not_na += (iter_label != 0).sum()
            if (tot_not_na > 0):
                sys.stdout.write(('[pretrain main model] epoch %d step %d time %.2f | loss: %f, not NA accuracy: %f, accuracy: %f\r' % (epoch, i, t, iter_loss, (float(tot_not_na_correct) / tot_not_na), (float(tot_correct) / tot))))
                sys.stdout.flush()
            i += 1
        print(('\nAverage iteration time: %f' % (time_sum / i)))
def pretrain_main_model(self, max_epoch):
    for epoch in range(max_epoch):
        print((('###### Epoch ' + str(epoch)) + ' ######'))
        tot_correct = 0
        tot_not_na_correct = 0
        tot = 0
        tot_not_na = 0
        i = 0
        time_sum = 0
        for (i, batch_data) in enumerate(self.train_data_loader):
            time_start = time.time()
            (iter_loss, iter_logit, _train_op) = self.one_step(self.sess, self.model, batch_data, [self.model.loss(), self.model.train_logit(), self.train_op])
            time_end = time.time()
            t = (time_end - time_start)
            time_sum += t
            iter_output = iter_logit.argmax((- 1))
            iter_label = batch_data['rel']
            iter_correct = (iter_output == iter_label).sum()
            iter_not_na_correct = np.logical_and((iter_output == iter_label), (iter_label != 0)).sum()
            tot_correct += iter_correct
            tot_not_na_correct += iter_not_na_correct
            tot += iter_label.shape[0]
            tot_not_na += (iter_label != 0).sum()
            if (tot_not_na > 0):
                sys.stdout.write(('[pretrain main model] epoch %d step %d time %.2f | loss: %f, not NA accuracy: %f, accuracy: %f\r' % (epoch, i, t, iter_loss, (float(tot_not_na_correct) / tot_not_na), (float(tot_correct) / tot))))
                sys.stdout.flush()
            i += 1
        print(('\nAverage iteration time: %f' % (time_sum / i)))