Fixup no_trainer examples scripts and add more tests (#16765)
* Change tracking to store_true * Remove step param and use it in the log dictionary directly * use vars(args) when passing args to init_trackers * Include tracking tests since tensorboard is already a dep
This commit is contained in:
@@ -277,7 +277,7 @@ def parse_args():
|
||||
)
|
||||
parser.add_argument(
|
||||
"--with_tracking",
|
||||
required=False,
|
||||
action="store_true",
|
||||
help="Whether to load in all available experiment trackers from the environment and use them for logging.",
|
||||
)
|
||||
args = parser.parse_args()
|
||||
@@ -315,7 +315,7 @@ def main():
|
||||
)
|
||||
# Initialize the accelerator. We will let the accelerator handle device placement for us in this example.
|
||||
# If we're using tracking, we also need to initialize it here and it will pick up all supported trackers in the environment
|
||||
accelerator = Accelerator(log_with="all") if args.with_tracking else Accelerator()
|
||||
accelerator = Accelerator(log_with="all", logging_dir=args.output_dir) if args.with_tracking else Accelerator()
|
||||
# Make one log on every process with the configuration for debugging.
|
||||
logging.basicConfig(
|
||||
format="%(asctime)s - %(levelname)s - %(name)s - %(message)s",
|
||||
@@ -548,7 +548,10 @@ def main():
|
||||
|
||||
# We need to initialize the trackers we use, and also store our configuration
|
||||
if args.with_tracking:
|
||||
accelerator.init_trackers("summarization_no_trainer", args)
|
||||
experiment_config = vars(args)
|
||||
# TensorBoard cannot log Enums, need the raw value
|
||||
experiment_config["lr_scheduler_type"] = experiment_config["lr_scheduler_type"].value
|
||||
accelerator.init_trackers("summarization_no_trainer", experiment_config)
|
||||
|
||||
# Metric
|
||||
metric = load_metric("rouge")
|
||||
@@ -666,7 +669,8 @@ def main():
|
||||
if args.with_tracking:
|
||||
result["train_loss"] = total_loss
|
||||
result["epoch"] = epoch
|
||||
accelerator.log(result, step=completed_steps)
|
||||
result["step"] = completed_steps
|
||||
accelerator.log(result)
|
||||
|
||||
if args.push_to_hub and epoch < args.num_train_epochs - 1:
|
||||
accelerator.wait_for_everyone()
|
||||
|
||||
Reference in New Issue
Block a user