Skip to content

Commit

Permalink
Reset parameters if hidden size is changed
Browse files Browse the repository at this point in the history
  • Loading branch information
hm-ysjiang committed Jun 7, 2023
1 parent b7546ea commit c41db70
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
8 changes: 7 additions & 1 deletion train-selfsupervised.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,13 @@ def train(args):
if args.reset_context:
_weight = OrderedDict()
for key, val in checkpoint.items():
if '.cnet.' not in key and '.update_block.gru.' not in key:
if args.context != 128 and \
('.cnet.' in key or '.update_block.gru.' in key):
pass
elif args.hidden != 128 and \
('.update_block.gru.' in key or '.update_block.flow_head.' in key):
pass
else:
_weight[key] = val
weight = _weight
model.load_state_dict(weight, strict=(not args.allow_nonstrict))
Expand Down
8 changes: 7 additions & 1 deletion train-supervised.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,13 @@ def train(args):
if args.reset_context:
_weight = OrderedDict()
for key, val in checkpoint.items():
if '.cnet.' not in key and '.update_block.gru.' not in key:
if args.context != 128 and \
('.cnet.' in key or '.update_block.gru.' in key):
pass
elif args.hidden != 128 and \
('.update_block.gru.' in key or '.update_block.flow_head.' in key):
pass
else:
_weight[key] = val
weight = _weight
model.load_state_dict(weight, strict=(not args.allow_nonstrict))
Expand Down

0 comments on commit c41db70

Please sign in to comment.