From 17e3fb3502c56012b2e503911385b30b060d3db1 Mon Sep 17 00:00:00 2001 From: Antonio Kim Date: Sun, 23 Aug 2020 13:14:55 +0000 Subject: [PATCH] Fixed training script --- .gitignore | 3 ++- data | 1 - model/Pro-GAN/params256.yml | 4 ++-- model/Pro-GAN/params512.yml | 6 +++--- model/Pro-GAN/train.py | 12 ++++++------ model/Pro-GAN/train.sh | 6 +++--- requirements.txt | 1 + 7 files changed, 17 insertions(+), 16 deletions(-) delete mode 120000 data mode change 100644 => 100755 model/Pro-GAN/train.sh diff --git a/.gitignore b/.gitignore index 636b1bf..82a9b0c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,6 @@ *.tar *ipynb_checkpoint* *pycache* +data data/ -model/Pro-GAN_scraps.txt \ No newline at end of file +model/Pro-GAN_scraps.txt diff --git a/data b/data deleted file mode 120000 index 604a098..0000000 --- a/data +++ /dev/null @@ -1 +0,0 @@ -/media/antonio/HDD-1/Projects Backup/Deep Learning Projects/DeepHubble \ No newline at end of file diff --git a/model/Pro-GAN/params256.yml b/model/Pro-GAN/params256.yml index c879d45..44dab0f 100644 --- a/model/Pro-GAN/params256.yml +++ b/model/Pro-GAN/params256.yml @@ -1,6 +1,6 @@ resolution: 256 batch_size: 32 -learning_rate: 0.0005 +learning_rate: 0.00025 save_interval: 200 save_model_path: "../../data/checkpoints" -log_path: "../../data/images" \ No newline at end of file +log_path: "../../data/images" diff --git a/model/Pro-GAN/params512.yml b/model/Pro-GAN/params512.yml index 607b2c7..065cbc5 100644 --- a/model/Pro-GAN/params512.yml +++ b/model/Pro-GAN/params512.yml @@ -1,6 +1,6 @@ resolution: 512 batch_size: 32 -learning_rate: 0.0005 -save_interval: 200 +learning_rate: 0.0001 +save_interval: 250 save_model_path: "../../data/checkpoints" -log_path: "../../data/images" \ No newline at end of file +log_path: "../../data/images" diff --git a/model/Pro-GAN/train.py b/model/Pro-GAN/train.py index 2a9f165..444b976 100644 --- a/model/Pro-GAN/train.py +++ b/model/Pro-GAN/train.py @@ -56,11 +56,11 @@ def FromTensor(tensor): return np.moveaxis(tensor.detach().cpu().numpy(), 1, -1) -def generate_fake_images(generator, params, suffix=""): +def generate_fake_images(generator, alpha, params, suffix=""): res = params.resolution noise = generate_noise(generator, 4) - fake_output = generator.forward(noise, alpha=0) + fake_output = generator.forward(noise, alpha=alpha) fake_output = FromTensor(fake_output) fig, ax = plt.subplots(2, 2, figsize=(10, 11)) @@ -117,7 +117,7 @@ def train(args): print("\n"+"-"*80+"\n") - generate_fake_images(generator, params, "Untrained") + generate_fake_images(generator, 0, params, "Untrained") dataloader = torch.utils.data.DataLoader( Dataset(resolution=resolution, size=800000), @@ -180,7 +180,7 @@ def train(fade_in: bool): ) progress.update() - if abs(discriminator_err.item()) > 50: + if abs(discriminator_err.item()) > 100: raise Exception("Training has diverged.") generator_losses.append(generator_err.item()) @@ -204,7 +204,7 @@ def train(fade_in: bool): ) ) - generate_fake_images(generator, params, f"Pro-GAN Iteration {iteration}") + generate_fake_images(generator, alpha, params, f"Pro-GAN Iteration {iteration}") pd.DataFrame( { @@ -246,7 +246,7 @@ def train(fade_in: bool): train(fade_in=False) - generate_fake_images(generator, params, "Trained") + generate_fake_images(generator, 1, params, "Trained") generator.save( os.path.join( diff --git a/model/Pro-GAN/train.sh b/model/Pro-GAN/train.sh old mode 100644 new mode 100755 index 57e201d..4b9e7ba --- a/model/Pro-GAN/train.sh +++ b/model/Pro-GAN/train.sh @@ -1,6 +1,6 @@ #!/bin/bash -python -u train.py --param-file params128.yml -python -u train.py --param-file params256.yml -# python -u train.py --param-file params512.yml +# python -u train.py --param-file params128.yml +# python -u train.py --param-file params256.yml +python -u train.py --param-file params512.yml diff --git a/requirements.txt b/requirements.txt index 711c893..4cede22 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ git+https://github.com/antoniojkim/TorchX.git matplotlib numpy +pandas pillow torch torchvision