Don't log anything before logging is setup in examples (#12121)
* Don't log anything before logging is setup in examples * Last example
This commit is contained in:
@@ -194,21 +194,6 @@ def main():
|
|||||||
else:
|
else:
|
||||||
model_args, data_args, training_args = parser.parse_args_into_dataclasses()
|
model_args, data_args, training_args = parser.parse_args_into_dataclasses()
|
||||||
|
|
||||||
# Detecting last checkpoint.
|
|
||||||
last_checkpoint = None
|
|
||||||
if os.path.isdir(training_args.output_dir) and training_args.do_train and not training_args.overwrite_output_dir:
|
|
||||||
last_checkpoint = get_last_checkpoint(training_args.output_dir)
|
|
||||||
if last_checkpoint is None and len(os.listdir(training_args.output_dir)) > 0:
|
|
||||||
raise ValueError(
|
|
||||||
f"Output directory ({training_args.output_dir}) already exists and is not empty. "
|
|
||||||
"Use --overwrite_output_dir to overcome."
|
|
||||||
)
|
|
||||||
elif last_checkpoint is not None and training_args.resume_from_checkpoint is None:
|
|
||||||
logger.info(
|
|
||||||
f"Checkpoint detected, resuming training at {last_checkpoint}. To avoid this behavior, change "
|
|
||||||
"the `--output_dir` or add `--overwrite_output_dir` to train from scratch."
|
|
||||||
)
|
|
||||||
|
|
||||||
# Setup logging
|
# Setup logging
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
|
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
|
||||||
@@ -229,6 +214,21 @@ def main():
|
|||||||
transformers.utils.logging.enable_explicit_format()
|
transformers.utils.logging.enable_explicit_format()
|
||||||
logger.info(f"Training/evaluation parameters {training_args}")
|
logger.info(f"Training/evaluation parameters {training_args}")
|
||||||
|
|
||||||
|
# Detecting last checkpoint.
|
||||||
|
last_checkpoint = None
|
||||||
|
if os.path.isdir(training_args.output_dir) and training_args.do_train and not training_args.overwrite_output_dir:
|
||||||
|
last_checkpoint = get_last_checkpoint(training_args.output_dir)
|
||||||
|
if last_checkpoint is None and len(os.listdir(training_args.output_dir)) > 0:
|
||||||
|
raise ValueError(
|
||||||
|
f"Output directory ({training_args.output_dir}) already exists and is not empty. "
|
||||||
|
"Use --overwrite_output_dir to overcome."
|
||||||
|
)
|
||||||
|
elif last_checkpoint is not None and training_args.resume_from_checkpoint is None:
|
||||||
|
logger.info(
|
||||||
|
f"Checkpoint detected, resuming training at {last_checkpoint}. To avoid this behavior, change "
|
||||||
|
"the `--output_dir` or add `--overwrite_output_dir` to train from scratch."
|
||||||
|
)
|
||||||
|
|
||||||
# Set seed before initializing model.
|
# Set seed before initializing model.
|
||||||
set_seed(training_args.seed)
|
set_seed(training_args.seed)
|
||||||
|
|
||||||
|
|||||||
@@ -190,21 +190,6 @@ def main():
|
|||||||
else:
|
else:
|
||||||
model_args, data_args, training_args = parser.parse_args_into_dataclasses()
|
model_args, data_args, training_args = parser.parse_args_into_dataclasses()
|
||||||
|
|
||||||
# Detecting last checkpoint.
|
|
||||||
last_checkpoint = None
|
|
||||||
if os.path.isdir(training_args.output_dir) and training_args.do_train and not training_args.overwrite_output_dir:
|
|
||||||
last_checkpoint = get_last_checkpoint(training_args.output_dir)
|
|
||||||
if last_checkpoint is None and len(os.listdir(training_args.output_dir)) > 0:
|
|
||||||
raise ValueError(
|
|
||||||
f"Output directory ({training_args.output_dir}) already exists and is not empty. "
|
|
||||||
"Use --overwrite_output_dir to overcome."
|
|
||||||
)
|
|
||||||
elif last_checkpoint is not None and training_args.resume_from_checkpoint is None:
|
|
||||||
logger.info(
|
|
||||||
f"Checkpoint detected, resuming training at {last_checkpoint}. To avoid this behavior, change "
|
|
||||||
"the `--output_dir` or add `--overwrite_output_dir` to train from scratch."
|
|
||||||
)
|
|
||||||
|
|
||||||
# Setup logging
|
# Setup logging
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
|
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
|
||||||
@@ -225,6 +210,21 @@ def main():
|
|||||||
transformers.utils.logging.enable_explicit_format()
|
transformers.utils.logging.enable_explicit_format()
|
||||||
logger.info(f"Training/evaluation parameters {training_args}")
|
logger.info(f"Training/evaluation parameters {training_args}")
|
||||||
|
|
||||||
|
# Detecting last checkpoint.
|
||||||
|
last_checkpoint = None
|
||||||
|
if os.path.isdir(training_args.output_dir) and training_args.do_train and not training_args.overwrite_output_dir:
|
||||||
|
last_checkpoint = get_last_checkpoint(training_args.output_dir)
|
||||||
|
if last_checkpoint is None and len(os.listdir(training_args.output_dir)) > 0:
|
||||||
|
raise ValueError(
|
||||||
|
f"Output directory ({training_args.output_dir}) already exists and is not empty. "
|
||||||
|
"Use --overwrite_output_dir to overcome."
|
||||||
|
)
|
||||||
|
elif last_checkpoint is not None and training_args.resume_from_checkpoint is None:
|
||||||
|
logger.info(
|
||||||
|
f"Checkpoint detected, resuming training at {last_checkpoint}. To avoid this behavior, change "
|
||||||
|
"the `--output_dir` or add `--overwrite_output_dir` to train from scratch."
|
||||||
|
)
|
||||||
|
|
||||||
# Set seed before initializing model.
|
# Set seed before initializing model.
|
||||||
set_seed(training_args.seed)
|
set_seed(training_args.seed)
|
||||||
|
|
||||||
|
|||||||
@@ -187,21 +187,6 @@ def main():
|
|||||||
else:
|
else:
|
||||||
model_args, data_args, training_args = parser.parse_args_into_dataclasses()
|
model_args, data_args, training_args = parser.parse_args_into_dataclasses()
|
||||||
|
|
||||||
# Detecting last checkpoint.
|
|
||||||
last_checkpoint = None
|
|
||||||
if os.path.isdir(training_args.output_dir) and training_args.do_train and not training_args.overwrite_output_dir:
|
|
||||||
last_checkpoint = get_last_checkpoint(training_args.output_dir)
|
|
||||||
if last_checkpoint is None and len(os.listdir(training_args.output_dir)) > 0:
|
|
||||||
raise ValueError(
|
|
||||||
f"Output directory ({training_args.output_dir}) already exists and is not empty. "
|
|
||||||
"Use --overwrite_output_dir to overcome."
|
|
||||||
)
|
|
||||||
elif last_checkpoint is not None and training_args.resume_from_checkpoint is None:
|
|
||||||
logger.info(
|
|
||||||
f"Checkpoint detected, resuming training at {last_checkpoint}. To avoid this behavior, change "
|
|
||||||
"the `--output_dir` or add `--overwrite_output_dir` to train from scratch."
|
|
||||||
)
|
|
||||||
|
|
||||||
# Setup logging
|
# Setup logging
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
|
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
|
||||||
@@ -222,6 +207,21 @@ def main():
|
|||||||
transformers.utils.logging.enable_explicit_format()
|
transformers.utils.logging.enable_explicit_format()
|
||||||
logger.info(f"Training/evaluation parameters {training_args}")
|
logger.info(f"Training/evaluation parameters {training_args}")
|
||||||
|
|
||||||
|
# Detecting last checkpoint.
|
||||||
|
last_checkpoint = None
|
||||||
|
if os.path.isdir(training_args.output_dir) and training_args.do_train and not training_args.overwrite_output_dir:
|
||||||
|
last_checkpoint = get_last_checkpoint(training_args.output_dir)
|
||||||
|
if last_checkpoint is None and len(os.listdir(training_args.output_dir)) > 0:
|
||||||
|
raise ValueError(
|
||||||
|
f"Output directory ({training_args.output_dir}) already exists and is not empty. "
|
||||||
|
"Use --overwrite_output_dir to overcome."
|
||||||
|
)
|
||||||
|
elif last_checkpoint is not None and training_args.resume_from_checkpoint is None:
|
||||||
|
logger.info(
|
||||||
|
f"Checkpoint detected, resuming training at {last_checkpoint}. To avoid this behavior, change "
|
||||||
|
"the `--output_dir` or add `--overwrite_output_dir` to train from scratch."
|
||||||
|
)
|
||||||
|
|
||||||
# Set seed before initializing model.
|
# Set seed before initializing model.
|
||||||
set_seed(training_args.seed)
|
set_seed(training_args.seed)
|
||||||
|
|
||||||
|
|||||||
@@ -214,21 +214,6 @@ def main():
|
|||||||
else:
|
else:
|
||||||
model_args, data_args, training_args = parser.parse_args_into_dataclasses()
|
model_args, data_args, training_args = parser.parse_args_into_dataclasses()
|
||||||
|
|
||||||
# Detecting last checkpoint.
|
|
||||||
last_checkpoint = None
|
|
||||||
if os.path.isdir(training_args.output_dir) and training_args.do_train and not training_args.overwrite_output_dir:
|
|
||||||
last_checkpoint = get_last_checkpoint(training_args.output_dir)
|
|
||||||
if last_checkpoint is None and len(os.listdir(training_args.output_dir)) > 0:
|
|
||||||
raise ValueError(
|
|
||||||
f"Output directory ({training_args.output_dir}) already exists and is not empty. "
|
|
||||||
"Use --overwrite_output_dir to overcome."
|
|
||||||
)
|
|
||||||
elif last_checkpoint is not None and training_args.resume_from_checkpoint is None:
|
|
||||||
logger.info(
|
|
||||||
f"Checkpoint detected, resuming training at {last_checkpoint}. To avoid this behavior, change "
|
|
||||||
"the `--output_dir` or add `--overwrite_output_dir` to train from scratch."
|
|
||||||
)
|
|
||||||
|
|
||||||
# Setup logging
|
# Setup logging
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
|
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
|
||||||
@@ -249,6 +234,21 @@ def main():
|
|||||||
transformers.utils.logging.enable_explicit_format()
|
transformers.utils.logging.enable_explicit_format()
|
||||||
logger.info(f"Training/evaluation parameters {training_args}")
|
logger.info(f"Training/evaluation parameters {training_args}")
|
||||||
|
|
||||||
|
# Detecting last checkpoint.
|
||||||
|
last_checkpoint = None
|
||||||
|
if os.path.isdir(training_args.output_dir) and training_args.do_train and not training_args.overwrite_output_dir:
|
||||||
|
last_checkpoint = get_last_checkpoint(training_args.output_dir)
|
||||||
|
if last_checkpoint is None and len(os.listdir(training_args.output_dir)) > 0:
|
||||||
|
raise ValueError(
|
||||||
|
f"Output directory ({training_args.output_dir}) already exists and is not empty. "
|
||||||
|
"Use --overwrite_output_dir to overcome."
|
||||||
|
)
|
||||||
|
elif last_checkpoint is not None and training_args.resume_from_checkpoint is None:
|
||||||
|
logger.info(
|
||||||
|
f"Checkpoint detected, resuming training at {last_checkpoint}. To avoid this behavior, change "
|
||||||
|
"the `--output_dir` or add `--overwrite_output_dir` to train from scratch."
|
||||||
|
)
|
||||||
|
|
||||||
# Set seed before initializing model.
|
# Set seed before initializing model.
|
||||||
set_seed(training_args.seed)
|
set_seed(training_args.seed)
|
||||||
|
|
||||||
|
|||||||
@@ -207,21 +207,6 @@ def main():
|
|||||||
else:
|
else:
|
||||||
model_args, data_args, training_args = parser.parse_args_into_dataclasses()
|
model_args, data_args, training_args = parser.parse_args_into_dataclasses()
|
||||||
|
|
||||||
# Detecting last checkpoint.
|
|
||||||
last_checkpoint = None
|
|
||||||
if os.path.isdir(training_args.output_dir) and training_args.do_train and not training_args.overwrite_output_dir:
|
|
||||||
last_checkpoint = get_last_checkpoint(training_args.output_dir)
|
|
||||||
if last_checkpoint is None and len(os.listdir(training_args.output_dir)) > 0:
|
|
||||||
raise ValueError(
|
|
||||||
f"Output directory ({training_args.output_dir}) already exists and is not empty. "
|
|
||||||
"Use --overwrite_output_dir to overcome."
|
|
||||||
)
|
|
||||||
elif last_checkpoint is not None and training_args.resume_from_checkpoint is None:
|
|
||||||
logger.info(
|
|
||||||
f"Checkpoint detected, resuming training at {last_checkpoint}. To avoid this behavior, change "
|
|
||||||
"the `--output_dir` or add `--overwrite_output_dir` to train from scratch."
|
|
||||||
)
|
|
||||||
|
|
||||||
# Setup logging
|
# Setup logging
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
|
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
|
||||||
@@ -242,6 +227,21 @@ def main():
|
|||||||
transformers.utils.logging.enable_explicit_format()
|
transformers.utils.logging.enable_explicit_format()
|
||||||
logger.info(f"Training/evaluation parameters {training_args}")
|
logger.info(f"Training/evaluation parameters {training_args}")
|
||||||
|
|
||||||
|
# Detecting last checkpoint.
|
||||||
|
last_checkpoint = None
|
||||||
|
if os.path.isdir(training_args.output_dir) and training_args.do_train and not training_args.overwrite_output_dir:
|
||||||
|
last_checkpoint = get_last_checkpoint(training_args.output_dir)
|
||||||
|
if last_checkpoint is None and len(os.listdir(training_args.output_dir)) > 0:
|
||||||
|
raise ValueError(
|
||||||
|
f"Output directory ({training_args.output_dir}) already exists and is not empty. "
|
||||||
|
"Use --overwrite_output_dir to overcome."
|
||||||
|
)
|
||||||
|
elif last_checkpoint is not None and training_args.resume_from_checkpoint is None:
|
||||||
|
logger.info(
|
||||||
|
f"Checkpoint detected, resuming training at {last_checkpoint}. To avoid this behavior, change "
|
||||||
|
"the `--output_dir` or add `--overwrite_output_dir` to train from scratch."
|
||||||
|
)
|
||||||
|
|
||||||
# Set seed before initializing model.
|
# Set seed before initializing model.
|
||||||
set_seed(training_args.seed)
|
set_seed(training_args.seed)
|
||||||
|
|
||||||
|
|||||||
@@ -206,21 +206,6 @@ def main():
|
|||||||
else:
|
else:
|
||||||
model_args, data_args, training_args = parser.parse_args_into_dataclasses()
|
model_args, data_args, training_args = parser.parse_args_into_dataclasses()
|
||||||
|
|
||||||
# Detecting last checkpoint.
|
|
||||||
last_checkpoint = None
|
|
||||||
if os.path.isdir(training_args.output_dir) and training_args.do_train and not training_args.overwrite_output_dir:
|
|
||||||
last_checkpoint = get_last_checkpoint(training_args.output_dir)
|
|
||||||
if last_checkpoint is None and len(os.listdir(training_args.output_dir)) > 0:
|
|
||||||
raise ValueError(
|
|
||||||
f"Output directory ({training_args.output_dir}) already exists and is not empty. "
|
|
||||||
"Use --overwrite_output_dir to overcome."
|
|
||||||
)
|
|
||||||
elif last_checkpoint is not None and training_args.resume_from_checkpoint is None:
|
|
||||||
logger.info(
|
|
||||||
f"Checkpoint detected, resuming training at {last_checkpoint}. To avoid this behavior, change "
|
|
||||||
"the `--output_dir` or add `--overwrite_output_dir` to train from scratch."
|
|
||||||
)
|
|
||||||
|
|
||||||
# Setup logging
|
# Setup logging
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
|
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
|
||||||
@@ -241,6 +226,21 @@ def main():
|
|||||||
transformers.utils.logging.enable_explicit_format()
|
transformers.utils.logging.enable_explicit_format()
|
||||||
logger.info(f"Training/evaluation parameters {training_args}")
|
logger.info(f"Training/evaluation parameters {training_args}")
|
||||||
|
|
||||||
|
# Detecting last checkpoint.
|
||||||
|
last_checkpoint = None
|
||||||
|
if os.path.isdir(training_args.output_dir) and training_args.do_train and not training_args.overwrite_output_dir:
|
||||||
|
last_checkpoint = get_last_checkpoint(training_args.output_dir)
|
||||||
|
if last_checkpoint is None and len(os.listdir(training_args.output_dir)) > 0:
|
||||||
|
raise ValueError(
|
||||||
|
f"Output directory ({training_args.output_dir}) already exists and is not empty. "
|
||||||
|
"Use --overwrite_output_dir to overcome."
|
||||||
|
)
|
||||||
|
elif last_checkpoint is not None and training_args.resume_from_checkpoint is None:
|
||||||
|
logger.info(
|
||||||
|
f"Checkpoint detected, resuming training at {last_checkpoint}. To avoid this behavior, change "
|
||||||
|
"the `--output_dir` or add `--overwrite_output_dir` to train from scratch."
|
||||||
|
)
|
||||||
|
|
||||||
# Set seed before initializing model.
|
# Set seed before initializing model.
|
||||||
set_seed(training_args.seed)
|
set_seed(training_args.seed)
|
||||||
|
|
||||||
|
|||||||
@@ -251,6 +251,24 @@ def main():
|
|||||||
else:
|
else:
|
||||||
model_args, data_args, training_args = parser.parse_args_into_dataclasses()
|
model_args, data_args, training_args = parser.parse_args_into_dataclasses()
|
||||||
|
|
||||||
|
# Setup logging
|
||||||
|
logging.basicConfig(
|
||||||
|
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
|
||||||
|
datefmt="%m/%d/%Y %H:%M:%S",
|
||||||
|
handlers=[logging.StreamHandler(sys.stdout)],
|
||||||
|
)
|
||||||
|
logger.setLevel(logging.INFO if training_args.should_log else logging.WARN)
|
||||||
|
|
||||||
|
# Log on each process the small summary:
|
||||||
|
logger.warning(
|
||||||
|
f"Process rank: {training_args.local_rank}, device: {training_args.device}, n_gpu: {training_args.n_gpu}"
|
||||||
|
+ f"distributed training: {bool(training_args.local_rank != -1)}, 16-bits training: {training_args.fp16}"
|
||||||
|
)
|
||||||
|
# Set the verbosity to info of the Transformers logger (on main process only):
|
||||||
|
if training_args.should_log:
|
||||||
|
transformers.utils.logging.set_verbosity_info()
|
||||||
|
logger.info(f"Training/evaluation parameters {training_args}")
|
||||||
|
|
||||||
if data_args.source_prefix is None and model_args.model_name_or_path in [
|
if data_args.source_prefix is None and model_args.model_name_or_path in [
|
||||||
"t5-small",
|
"t5-small",
|
||||||
"t5-base",
|
"t5-base",
|
||||||
@@ -278,24 +296,6 @@ def main():
|
|||||||
"the `--output_dir` or add `--overwrite_output_dir` to train from scratch."
|
"the `--output_dir` or add `--overwrite_output_dir` to train from scratch."
|
||||||
)
|
)
|
||||||
|
|
||||||
# Setup logging
|
|
||||||
logging.basicConfig(
|
|
||||||
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
|
|
||||||
datefmt="%m/%d/%Y %H:%M:%S",
|
|
||||||
handlers=[logging.StreamHandler(sys.stdout)],
|
|
||||||
)
|
|
||||||
logger.setLevel(logging.INFO if training_args.should_log else logging.WARN)
|
|
||||||
|
|
||||||
# Log on each process the small summary:
|
|
||||||
logger.warning(
|
|
||||||
f"Process rank: {training_args.local_rank}, device: {training_args.device}, n_gpu: {training_args.n_gpu}"
|
|
||||||
+ f"distributed training: {bool(training_args.local_rank != -1)}, 16-bits training: {training_args.fp16}"
|
|
||||||
)
|
|
||||||
# Set the verbosity to info of the Transformers logger (on main process only):
|
|
||||||
if training_args.should_log:
|
|
||||||
transformers.utils.logging.set_verbosity_info()
|
|
||||||
logger.info(f"Training/evaluation parameters {training_args}")
|
|
||||||
|
|
||||||
# Set seed before initializing model.
|
# Set seed before initializing model.
|
||||||
set_seed(training_args.seed)
|
set_seed(training_args.seed)
|
||||||
|
|
||||||
|
|||||||
@@ -197,21 +197,6 @@ def main():
|
|||||||
else:
|
else:
|
||||||
model_args, data_args, training_args = parser.parse_args_into_dataclasses()
|
model_args, data_args, training_args = parser.parse_args_into_dataclasses()
|
||||||
|
|
||||||
# Detecting last checkpoint.
|
|
||||||
last_checkpoint = None
|
|
||||||
if os.path.isdir(training_args.output_dir) and training_args.do_train and not training_args.overwrite_output_dir:
|
|
||||||
last_checkpoint = get_last_checkpoint(training_args.output_dir)
|
|
||||||
if last_checkpoint is None and len(os.listdir(training_args.output_dir)) > 0:
|
|
||||||
raise ValueError(
|
|
||||||
f"Output directory ({training_args.output_dir}) already exists and is not empty. "
|
|
||||||
"Use --overwrite_output_dir to overcome."
|
|
||||||
)
|
|
||||||
elif last_checkpoint is not None and training_args.resume_from_checkpoint is None:
|
|
||||||
logger.info(
|
|
||||||
f"Checkpoint detected, resuming training at {last_checkpoint}. To avoid this behavior, change "
|
|
||||||
"the `--output_dir` or add `--overwrite_output_dir` to train from scratch."
|
|
||||||
)
|
|
||||||
|
|
||||||
# Setup logging
|
# Setup logging
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
|
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
|
||||||
@@ -232,6 +217,21 @@ def main():
|
|||||||
transformers.utils.logging.enable_explicit_format()
|
transformers.utils.logging.enable_explicit_format()
|
||||||
logger.info(f"Training/evaluation parameters {training_args}")
|
logger.info(f"Training/evaluation parameters {training_args}")
|
||||||
|
|
||||||
|
# Detecting last checkpoint.
|
||||||
|
last_checkpoint = None
|
||||||
|
if os.path.isdir(training_args.output_dir) and training_args.do_train and not training_args.overwrite_output_dir:
|
||||||
|
last_checkpoint = get_last_checkpoint(training_args.output_dir)
|
||||||
|
if last_checkpoint is None and len(os.listdir(training_args.output_dir)) > 0:
|
||||||
|
raise ValueError(
|
||||||
|
f"Output directory ({training_args.output_dir}) already exists and is not empty. "
|
||||||
|
"Use --overwrite_output_dir to overcome."
|
||||||
|
)
|
||||||
|
elif last_checkpoint is not None and training_args.resume_from_checkpoint is None:
|
||||||
|
logger.info(
|
||||||
|
f"Checkpoint detected, resuming training at {last_checkpoint}. To avoid this behavior, change "
|
||||||
|
"the `--output_dir` or add `--overwrite_output_dir` to train from scratch."
|
||||||
|
)
|
||||||
|
|
||||||
# Set seed before initializing model.
|
# Set seed before initializing model.
|
||||||
set_seed(training_args.seed)
|
set_seed(training_args.seed)
|
||||||
|
|
||||||
|
|||||||
@@ -158,21 +158,6 @@ def main():
|
|||||||
parser = HfArgumentParser((ModelArguments, DataTrainingArguments, TrainingArguments))
|
parser = HfArgumentParser((ModelArguments, DataTrainingArguments, TrainingArguments))
|
||||||
model_args, data_args, training_args = parser.parse_args_into_dataclasses()
|
model_args, data_args, training_args = parser.parse_args_into_dataclasses()
|
||||||
|
|
||||||
# Detecting last checkpoint.
|
|
||||||
last_checkpoint = None
|
|
||||||
if os.path.isdir(training_args.output_dir) and training_args.do_train and not training_args.overwrite_output_dir:
|
|
||||||
last_checkpoint = get_last_checkpoint(training_args.output_dir)
|
|
||||||
if last_checkpoint is None and len(os.listdir(training_args.output_dir)) > 0:
|
|
||||||
raise ValueError(
|
|
||||||
f"Output directory ({training_args.output_dir}) already exists and is not empty. "
|
|
||||||
"Use --overwrite_output_dir to overcome."
|
|
||||||
)
|
|
||||||
elif last_checkpoint is not None:
|
|
||||||
logger.info(
|
|
||||||
f"Checkpoint detected, resuming training at {last_checkpoint}. To avoid this behavior, change "
|
|
||||||
"the `--output_dir` or add `--overwrite_output_dir` to train from scratch."
|
|
||||||
)
|
|
||||||
|
|
||||||
# Setup distant debugging if needed
|
# Setup distant debugging if needed
|
||||||
if data_args.server_ip and data_args.server_port:
|
if data_args.server_ip and data_args.server_port:
|
||||||
# Distant debugging - see https://code.visualstudio.com/docs/python/debugging#_attach-to-a-local-script
|
# Distant debugging - see https://code.visualstudio.com/docs/python/debugging#_attach-to-a-local-script
|
||||||
@@ -203,6 +188,21 @@ def main():
|
|||||||
transformers.utils.logging.enable_explicit_format()
|
transformers.utils.logging.enable_explicit_format()
|
||||||
logger.info(f"Training/evaluation parameters {training_args}")
|
logger.info(f"Training/evaluation parameters {training_args}")
|
||||||
|
|
||||||
|
# Detecting last checkpoint.
|
||||||
|
last_checkpoint = None
|
||||||
|
if os.path.isdir(training_args.output_dir) and training_args.do_train and not training_args.overwrite_output_dir:
|
||||||
|
last_checkpoint = get_last_checkpoint(training_args.output_dir)
|
||||||
|
if last_checkpoint is None and len(os.listdir(training_args.output_dir)) > 0:
|
||||||
|
raise ValueError(
|
||||||
|
f"Output directory ({training_args.output_dir}) already exists and is not empty. "
|
||||||
|
"Use --overwrite_output_dir to overcome."
|
||||||
|
)
|
||||||
|
elif last_checkpoint is not None:
|
||||||
|
logger.info(
|
||||||
|
f"Checkpoint detected, resuming training at {last_checkpoint}. To avoid this behavior, change "
|
||||||
|
"the `--output_dir` or add `--overwrite_output_dir` to train from scratch."
|
||||||
|
)
|
||||||
|
|
||||||
# Set seed before initializing model.
|
# Set seed before initializing model.
|
||||||
set_seed(training_args.seed)
|
set_seed(training_args.seed)
|
||||||
|
|
||||||
|
|||||||
@@ -186,21 +186,6 @@ def main():
|
|||||||
else:
|
else:
|
||||||
model_args, data_args, training_args = parser.parse_args_into_dataclasses()
|
model_args, data_args, training_args = parser.parse_args_into_dataclasses()
|
||||||
|
|
||||||
# Detecting last checkpoint.
|
|
||||||
last_checkpoint = None
|
|
||||||
if os.path.isdir(training_args.output_dir) and training_args.do_train and not training_args.overwrite_output_dir:
|
|
||||||
last_checkpoint = get_last_checkpoint(training_args.output_dir)
|
|
||||||
if last_checkpoint is None and len(os.listdir(training_args.output_dir)) > 0:
|
|
||||||
raise ValueError(
|
|
||||||
f"Output directory ({training_args.output_dir}) already exists and is not empty. "
|
|
||||||
"Use --overwrite_output_dir to overcome."
|
|
||||||
)
|
|
||||||
elif last_checkpoint is not None and training_args.resume_from_checkpoint is None:
|
|
||||||
logger.info(
|
|
||||||
f"Checkpoint detected, resuming training at {last_checkpoint}. To avoid this behavior, change "
|
|
||||||
"the `--output_dir` or add `--overwrite_output_dir` to train from scratch."
|
|
||||||
)
|
|
||||||
|
|
||||||
# Setup logging
|
# Setup logging
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
|
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
|
||||||
@@ -221,6 +206,21 @@ def main():
|
|||||||
transformers.utils.logging.enable_explicit_format()
|
transformers.utils.logging.enable_explicit_format()
|
||||||
logger.info(f"Training/evaluation parameters {training_args}")
|
logger.info(f"Training/evaluation parameters {training_args}")
|
||||||
|
|
||||||
|
# Detecting last checkpoint.
|
||||||
|
last_checkpoint = None
|
||||||
|
if os.path.isdir(training_args.output_dir) and training_args.do_train and not training_args.overwrite_output_dir:
|
||||||
|
last_checkpoint = get_last_checkpoint(training_args.output_dir)
|
||||||
|
if last_checkpoint is None and len(os.listdir(training_args.output_dir)) > 0:
|
||||||
|
raise ValueError(
|
||||||
|
f"Output directory ({training_args.output_dir}) already exists and is not empty. "
|
||||||
|
"Use --overwrite_output_dir to overcome."
|
||||||
|
)
|
||||||
|
elif last_checkpoint is not None and training_args.resume_from_checkpoint is None:
|
||||||
|
logger.info(
|
||||||
|
f"Checkpoint detected, resuming training at {last_checkpoint}. To avoid this behavior, change "
|
||||||
|
"the `--output_dir` or add `--overwrite_output_dir` to train from scratch."
|
||||||
|
)
|
||||||
|
|
||||||
# Set seed before initializing model.
|
# Set seed before initializing model.
|
||||||
set_seed(training_args.seed)
|
set_seed(training_args.seed)
|
||||||
|
|
||||||
|
|||||||
@@ -235,6 +235,24 @@ def main():
|
|||||||
else:
|
else:
|
||||||
model_args, data_args, training_args = parser.parse_args_into_dataclasses()
|
model_args, data_args, training_args = parser.parse_args_into_dataclasses()
|
||||||
|
|
||||||
|
# Setup logging
|
||||||
|
logging.basicConfig(
|
||||||
|
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
|
||||||
|
datefmt="%m/%d/%Y %H:%M:%S",
|
||||||
|
handlers=[logging.StreamHandler(sys.stdout)],
|
||||||
|
)
|
||||||
|
logger.setLevel(logging.INFO if training_args.should_log else logging.WARN)
|
||||||
|
|
||||||
|
# Log on each process the small summary:
|
||||||
|
logger.warning(
|
||||||
|
f"Process rank: {training_args.local_rank}, device: {training_args.device}, n_gpu: {training_args.n_gpu}"
|
||||||
|
+ f"distributed training: {bool(training_args.local_rank != -1)}, 16-bits training: {training_args.fp16}"
|
||||||
|
)
|
||||||
|
# Set the verbosity to info of the Transformers logger (on main process only):
|
||||||
|
if training_args.should_log:
|
||||||
|
transformers.utils.logging.set_verbosity_info()
|
||||||
|
logger.info(f"Training/evaluation parameters {training_args}")
|
||||||
|
|
||||||
if data_args.source_prefix is None and model_args.model_name_or_path in [
|
if data_args.source_prefix is None and model_args.model_name_or_path in [
|
||||||
"t5-small",
|
"t5-small",
|
||||||
"t5-base",
|
"t5-base",
|
||||||
@@ -262,24 +280,6 @@ def main():
|
|||||||
"the `--output_dir` or add `--overwrite_output_dir` to train from scratch."
|
"the `--output_dir` or add `--overwrite_output_dir` to train from scratch."
|
||||||
)
|
)
|
||||||
|
|
||||||
# Setup logging
|
|
||||||
logging.basicConfig(
|
|
||||||
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
|
|
||||||
datefmt="%m/%d/%Y %H:%M:%S",
|
|
||||||
handlers=[logging.StreamHandler(sys.stdout)],
|
|
||||||
)
|
|
||||||
logger.setLevel(logging.INFO if training_args.should_log else logging.WARN)
|
|
||||||
|
|
||||||
# Log on each process the small summary:
|
|
||||||
logger.warning(
|
|
||||||
f"Process rank: {training_args.local_rank}, device: {training_args.device}, n_gpu: {training_args.n_gpu}"
|
|
||||||
+ f"distributed training: {bool(training_args.local_rank != -1)}, 16-bits training: {training_args.fp16}"
|
|
||||||
)
|
|
||||||
# Set the verbosity to info of the Transformers logger (on main process only):
|
|
||||||
if training_args.should_log:
|
|
||||||
transformers.utils.logging.set_verbosity_info()
|
|
||||||
logger.info(f"Training/evaluation parameters {training_args}")
|
|
||||||
|
|
||||||
# Set seed before initializing model.
|
# Set seed before initializing model.
|
||||||
set_seed(training_args.seed)
|
set_seed(training_args.seed)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user