diff options
author | Jordan Gong <jordan.gong@protonmail.com> | 2021-01-22 18:12:41 +0800 |
---|---|---|
committer | Jordan Gong <jordan.gong@protonmail.com> | 2021-01-22 18:12:41 +0800 |
commit | 7b5ff0a8dd2406af74776f31b1e2afabf9fadacd (patch) | |
tree | 035b0a7d0002eb6226c47d7b4329e4d69f24848c /models/model.py | |
parent | 04c9d3210ff659bbe00dedb2d193a748e7a97b54 (diff) |
Handle unexpected restore iter
1. Skip finished model before load it
2. Raise error when restore iter is greater than total iter
Diffstat (limited to 'models/model.py')
-rw-r--r-- | models/model.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/models/model.py b/models/model.py index 3b54363..1a62bae 100644 --- a/models/model.py +++ b/models/model.py @@ -116,6 +116,13 @@ class Model: self.curr_iters, self.total_iters, dataset_selectors.items() ): print(f'Training model {condition} ...') + # Skip finished model + if curr_iter == total_iter: + continue + # Check invalid restore iter + elif curr_iter > total_iter: + raise ValueError("Restore iter '{}' should less than total " + "iter '{}'".format(curr_iter, total_iter)) self.curr_iter = curr_iter self.total_iter = total_iter self.fit( |