Skip to content

Commit

Permalink
Fix #1912 CoaT model not loading w/ return_interm_layers
Browse files Browse the repository at this point in the history
  • Loading branch information
rwightman committed Aug 10, 2023
1 parent c692715 commit 3a44e6c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions timm/models/coat.py
Original file line number Diff line number Diff line change
Expand Up @@ -690,8 +690,11 @@ def checkpoint_filter_fn(state_dict, model):
for k, v in state_dict.items():
# original model had unused norm layers, removing them requires filtering pretrained checkpoints
if k.startswith('norm1') or \
(model.norm2 is None and k.startswith('norm2')) or \
(model.norm3 is None and k.startswith('norm3')):
(k.startswith('norm2') and getattr(model, 'norm2', None) is None) or \
(k.startswith('norm3') and getattr(model, 'norm3', None) is None) or \
(k.startswith('norm4') and getattr(model, 'norm4', None) is None) or \
(k.startswith('aggregate') and getattr(model, 'aggregate', None) is None) or \
(k.startswith('head') and getattr(model, 'head', None) is None):
continue
out_dict[k] = v
return out_dict
Expand Down

0 comments on commit 3a44e6c

Please sign in to comment.