Hi, I train my model like this:
def get_pred(model, tr, val, te, epochs, model_state):
    model.load_state_dict(model_state)
    seed_torch(SEED)
    model.cuda()

    loss_fn = torch.nn.BCEWithLogitsLoss()

    optimizer = torch.optim.RMSprop(model.parameters())

    scheduler = CyclicLR(optimizer, base_lr=0.001, max_lr=0.002,
                         step_size=300, mode='exp_range',
                         gamma=0.99994)

    for epoch in range(epochs):

        start_time = time.time()

        model.train()
        avg_loss = 0.
        for x_batch, x_fe_batch, y_batch in tqdm(tr, disable=True):
            scheduler.batch_step()
            y_pred = model(x_batch, x_fe_batch)
            #             print(y_pred.size(), y_batch.size())
            loss = loss_fn(y_pred, y_batch.unsqueeze(1))
            optimizer.zero_grad()
            loss.backward()

            optimizer.step()
            avg_loss += loss.item() / len(tr)

        # model.eval()
        # if epoch == epochs-1:
        model.eval()
        valid_preds_fold = np.zeros((x_val_fold.size(0)))
        test_preds_fold = np.zeros(len(test_X))
        avg_val_loss = 0.
        for i, (x_batch, x_fe_batch, y_batch) in enumerate(val):
            y_pred = model(x_batch, x_fe_batch).detach()
            avg_val_loss += loss_fn(y_pred, y_batch.unsqueeze(1)).item() / len(val)
            valid_preds_fold[i * batch_size * 8:(i + 1) * batch_size * 8] = sigmoid(y_pred.cpu().numpy())[:, 0]

        # threshold_search(y_val_fold.cpu(), valid_preds_fold)
        elapsed_time = time.time() - start_time
        logger.info('Epoch {}/{} \t loss={:.4f} \t val_loss={:.4f} \t time={:.2f}s'.format(
            epoch + 1, epochs, avg_loss, avg_val_loss, elapsed_time))

    for i, (x_batch, x_fe_batch,) in enumerate(te):
        y_pred = model(x_batch, x_fe_batch).detach()

        test_preds_fold[i * batch_size * 8:(i + 1) * batch_size * 8] = sigmoid(y_pred.cpu().numpy())[:, 0]

    return valid_preds_fold, test_preds_fold

To save time, I modified it to do validation only  in the last epoch:
def get_pred(model, tr, val, te, epochs, model_state):
    model.load_state_dict(model_state)
    seed_torch(SEED)
    model.cuda()

    loss_fn = torch.nn.BCEWithLogitsLoss()

    optimizer = torch.optim.RMSprop(model.parameters())

    scheduler = CyclicLR(optimizer, base_lr=0.001, max_lr=0.002,
                         step_size=300, mode='exp_range',
                         gamma=0.99994)

    for epoch in range(epochs):

        start_time = time.time()

        model.train()
        avg_loss = 0.
        for x_batch, x_fe_batch, y_batch in tqdm(tr, disable=True):
            scheduler.batch_step()
            y_pred = model(x_batch, x_fe_batch)
            #             print(y_pred.size(), y_batch.size())
            loss = loss_fn(y_pred, y_batch.unsqueeze(1))
            optimizer.zero_grad()
            loss.backward()

            optimizer.step()
            avg_loss += loss.item() / len(tr)

        # model.eval()
        if epoch == epochs-1:
            model.eval()
            valid_preds_fold = np.zeros((x_val_fold.size(0)))
            test_preds_fold = np.zeros(len(test_X))
            avg_val_loss = 0.
            for i, (x_batch, x_fe_batch, y_batch) in enumerate(val):
                y_pred = model(x_batch, x_fe_batch).detach()
                avg_val_loss += loss_fn(y_pred, y_batch.unsqueeze(1)).item() / len(val)
                valid_preds_fold[i * batch_size * 8:(i + 1) * batch_size * 8] = sigmoid(y_pred.cpu().numpy())[:, 0]

            # threshold_search(y_val_fold.cpu(), valid_preds_fold)
            elapsed_time = time.time() - start_time
            logger.info('Epoch {}/{} \t loss={:.4f} \t val_loss={:.4f} \t time={:.2f}s'.format(
                epoch + 1, epochs, avg_loss, avg_val_loss, elapsed_time))

    for i, (x_batch, x_fe_batch,) in enumerate(te):
        y_pred = model(x_batch, x_fe_batch).detach()

        test_preds_fold[i * batch_size * 8:(i + 1) * batch_size * 8] = sigmoid(y_pred.cpu().numpy())[:, 0]

    return valid_preds_fold, test_preds_fold

But after the modification, I got a different validation result. How can I modify it to get the same result?
Thanks~~