"netD_lr": lambda: np.random.uniform(1e-2, 1e-5), }) tune_iter = 5 if args.smoke_test else 300 analysis = tune.run( PytorchTrainable, name="pbt_dcgan_mnist", scheduler=scheduler, reuse_actors=True, verbose=1, checkpoint_at_end=True, stop={ "training_iteration": tune_iter, }, num_samples=8, export_formats=[ExportFormat.MODEL], config={ "netG_lr": tune.sample_from( lambda spec: random.choice([0.0001, 0.0002, 0.0005])), "netD_lr": tune.sample_from( lambda spec: random.choice([0.0001, 0.0002, 0.0005])), "mnist_model_ref": mnist_model_ref }) # __tune_end__ # demo of the trained Generators if not args.smoke_test: logdirs = analysis.dataframe()["logdir"].tolist() model_paths = [os.path.join(d, "exported_models") for d in logdirs] demo_gan(analysis, model_paths)
) tune_iter = 5 if args.smoke_test else 300 analysis = tune.run( dcgan_train, name="pbt_dcgan_mnist", scheduler=scheduler, verbose=1, stop={ "training_iteration": tune_iter, }, metric="is_score", mode="max", num_samples=8, config={ "netG_lr": tune.choice([0.0001, 0.0002, 0.0005]), "netD_lr": tune.choice([0.0001, 0.0002, 0.0005]), "mnist_model_ref": mnist_model_ref, }, ) # __tune_end__ # demo of the trained Generators if not args.smoke_test: all_trials = analysis.trials checkpoint_paths = [ os.path.join(analysis.get_best_checkpoint(t), "checkpoint") for t in all_trials ] demo_gan(analysis, checkpoint_paths)