Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

多个epoch结果 #13

Open
Zhangmanman-ict opened this issue May 9, 2023 · 1 comment
Open

多个epoch结果 #13

Zhangmanman-ict opened this issue May 9, 2023 · 1 comment

Comments

@Zhangmanman-ict
Copy link

为什么训练了多个epoch,结果没有变化,和训练一轮一样

@taishan1994
Copy link
Owner

taishan1994 commented May 9, 2023

为什么训练了多个epoch,结果没有变化,和训练一轮一样

可能之前framework/framework.py里面我限制了:

if epoch == 0:
        eval_start_time = time.time()
        model.eval()
        # call the test function
        precision, recall, f1_score = self.test(test_data_loader, model, current_f1=best_f1_score, output=self.config.result_save_name)
        
        self.logging('epoch {:3d}, eval time: {:5.2f}s, f1: {:4.3f}, precision: {:4.3f}, recall: {:4.3f}'.
                     format(epoch, time.time() - eval_start_time, f1_score, precision, recall))
        
        if f1_score > best_f1_score:
            best_f1_score = f1_score
            best_epoch = epoch
            best_precision = precision
            best_recall = recall
            self.logging("saving the model, epoch: {:3d}, precision: {:4.3f}, recall: {:4.3f}, best f1: {:4.3f}".
                         format(best_epoch, best_precision, best_recall, best_f1_score))
            # save the best model
            path = os.path.join(self.config.checkpoint_dir, self.config.model_save_name)
            if not self.config.debug:
                torch.save(ori_model.state_dict(), path)
        
model.train()

你可以把这里改一下。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants