[trainer] parametrize default output_dir (#9352)

This PR:

* fixes trainer to have the logger agree with the actual default `output_dir`, but setting it one place and passing it as an argument to both places

@sgugger
This commit is contained in:
Stas Bekman
2021-01-04 07:14:32 -08:00
committed by GitHub
parent d735b074d7
commit d018afced0

View File

@@ -228,8 +228,9 @@ class Trainer:
optimizers: Tuple[torch.optim.Optimizer, torch.optim.lr_scheduler.LambdaLR] = (None, None), optimizers: Tuple[torch.optim.Optimizer, torch.optim.lr_scheduler.LambdaLR] = (None, None),
): ):
if args is None: if args is None:
logger.info("No `TrainingArguments` passed, using the current path as `output_dir`.") output_dir = "tmp_trainer"
args = TrainingArguments("tmp_trainer") logger.info(f"No `TrainingArguments` passed, using `output_dir={output_dir}`.")
args = TrainingArguments(output_dir=output_dir)
self.args = args self.args = args
# Seed must be set before instantiating the model when using model # Seed must be set before instantiating the model when using model
set_seed(self.args.seed) set_seed(self.args.seed)