Skip to content

Commit d506495

Browse files
authored
Check None before going through iteration (huggingface#13250)
* Check None before going through iteration * Format
1 parent 774760e commit d506495

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/transformers/trainer.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1411,7 +1411,9 @@ def _load_state_dict_in_model(self, state_dict):
14111411
load_result = self.model.load_state_dict(state_dict, strict=False)
14121412

14131413
if len(load_result.missing_keys) != 0:
1414-
if set(load_result.missing_keys) == set(self.model._keys_to_ignore_on_save):
1414+
if self.model._keys_to_ignore_on_save is not None and set(load_result.missing_keys) == set(
1415+
self.model._keys_to_ignore_on_save
1416+
):
14151417
self.model.tie_weights()
14161418
else:
14171419
logger.warn(f"There were missing keys in the checkpoint model loaded: {load_result.missing_keys}.")

0 commit comments

Comments
 (0)