When bert distillation runs on saving model after training, an error occurs
1049451037 opened this issue · comments
save_checkpoint(args.iteration, model, optimizer, lr_scheduler, args)
File "/home/lvqingsong/new/SwissArmyTransformer/SwissArmyTransformer/training/model_io.py", line 82, in
save_checkpoint
model_specific_args = extract_model_specific_args_from_model(args, module)
File "/home/lvqingsong/new/SwissArmyTransformer/SwissArmyTransformer/training/model_io.py", line 44, in
extract_model_specific_args_from_model
md.add_model_specific_args(parser)
File "/home/lvqingsong/new/SwissArmyTransformer/examples/bert/bert_ft_model.py", line 18, in add_model_
specific_args
return super().add_model_specific_args(parser)
File "/home/lvqingsong/new/SwissArmyTransformer/SwissArmyTransformer/model/official/bert_model.py", lin
e 48, in add_model_specific_args
group.add_argument('--num-types', type=int)
File "/usr/lib/python3.8/argparse.py", line 1398, in add_argument
return self._add_action(action)
File "/usr/lib/python3.8/argparse.py", line 1602, in _add_action
action = super(_ArgumentGroup, self)._add_action(action)
File "/usr/lib/python3.8/argparse.py", line 1412, in _add_action
self._check_conflict(action)
File "/usr/lib/python3.8/argparse.py", line 1551, in _check_conflict
conflict_handler(action, confl_optionals)
File "/usr/lib/python3.8/argparse.py", line 1560, in _handle_conflict_error
raise ArgumentError(action, message % conflict_string)
argparse.ArgumentError: argument --num-types: conflicting option string: --num-types
It seems that --num_types
argument both in teacher and student model, which causes a conflict when extracting args. Is there anyway to fix this? @Sleepychord @dm-thu
Maybe we can check if there is a duplication when enumerating the sub-models when saving? How do you think?
Here is the branch that I fix DistillModel save and load problem: #61
merged!