init OptimWrapper after resume (#362)

This commit is contained in:
Mashiro 2022-07-14 20:10:48 +08:00 committed by GitHub
parent 45001a1f6f
commit c9c6d454f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1592,16 +1592,17 @@ class Runner:
self._val_loop) # type: ignore
self.call_hook('before_run')
# TODO: add a contextmanager to avoid calling `before_run` many times
# make sure checkpoint-related hooks are triggered after `before_run`
self.load_or_resume()
# Initiate inner count of `optim_wrapper`.
self.optim_wrapper.initialize_count_status(
self.model,
self._train_loop.iter, # type: ignore
self._train_loop.max_iters) # type: ignore
# TODO: add a contextmanager to avoid calling `before_run` many times
# make sure checkpoint-related hooks are triggered after `before_run`
self.load_or_resume()
self.train_loop.run() # type: ignore
self.call_hook('after_run')