From e0d6a259ae75ba7fdf4a37f8560a8097a1081f9d Mon Sep 17 00:00:00 2001 From: xuyige Date: Wed, 23 Jan 2019 17:09:28 +0800 Subject: [PATCH] skip training while n_epoch in trainer is not greater than 0 --- fastNLP/core/trainer.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fastNLP/core/trainer.py b/fastNLP/core/trainer.py index 8112af88..ed2f366b 100644 --- a/fastNLP/core/trainer.py +++ b/fastNLP/core/trainer.py @@ -181,6 +181,10 @@ class Trainer(object): """ results = {} + if self.n_epochs <= 0: + print(f"training epoch is {self.n_epochs}, nothing was done.") + results['seconds'] = 0. + return results try: if torch.cuda.is_available() and self.use_cuda: self.model = self.model.cuda()