Check None before going through iteration (#13250)

* Check None before going through iteration

* Format
This commit is contained in:
Li-Huai (Allan) Lin 2021-08-30 20:18:51 +08:00 committed by GitHub
parent 774760e6f3
commit d50649531f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1411,7 +1411,9 @@ class Trainer:
load_result = self.model.load_state_dict(state_dict, strict=False)
if len(load_result.missing_keys) != 0:
if set(load_result.missing_keys) == set(self.model._keys_to_ignore_on_save):
if self.model._keys_to_ignore_on_save is not None and set(load_result.missing_keys) == set(
self.model._keys_to_ignore_on_save
):
self.model.tie_weights()
else:
logger.warn(f"There were missing keys in the checkpoint model loaded: {load_result.missing_keys}.")