Unverified Commit 9f657f10 authored by Anish Shah's avatar Anish Shah Committed by GitHub
Browse files

[Examples] Update train_unconditional.py to include logging argument for Wandb (#1719)

Update train_unconditional.py

Add logger flag to choose between tensorboard and wandb
parent ce1c27ad
...@@ -173,6 +173,16 @@ def parse_args(): ...@@ -173,6 +173,16 @@ def parse_args():
parser.add_argument( parser.add_argument(
"--hub_private_repo", action="store_true", help="Whether or not to create a private repository." "--hub_private_repo", action="store_true", help="Whether or not to create a private repository."
) )
parser.add_argument(
"--logger",
type=str,
default="tensorboard",
choices=["tensorboard", "wandb"],
help=(
"Whether to use [tensorboard](https://www.tensorflow.org/tensorboard) or [wandb](https://www.wandb.ai)"
" for experiment tracking and logging of model metrics and model checkpoints"
),
)
parser.add_argument( parser.add_argument(
"--logging_dir", "--logging_dir",
type=str, type=str,
...@@ -248,7 +258,7 @@ def main(args): ...@@ -248,7 +258,7 @@ def main(args):
accelerator = Accelerator( accelerator = Accelerator(
gradient_accumulation_steps=args.gradient_accumulation_steps, gradient_accumulation_steps=args.gradient_accumulation_steps,
mixed_precision=args.mixed_precision, mixed_precision=args.mixed_precision,
log_with="tensorboard", log_with=args.logger,
logging_dir=logging_dir, logging_dir=logging_dir,
) )
...@@ -477,7 +487,9 @@ def main(args): ...@@ -477,7 +487,9 @@ def main(args):
# denormalize the images and save to tensorboard # denormalize the images and save to tensorboard
images_processed = (images * 255).round().astype("uint8") images_processed = (images * 255).round().astype("uint8")
accelerator.trackers[0].writer.add_images(
if args.logger == "tensorboard":
accelerator.get_tracker("tensorboard").add_images(
"test_samples", images_processed.transpose(0, 3, 1, 2), epoch "test_samples", images_processed.transpose(0, 3, 1, 2), epoch
) )
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment