diff --git a/README.md b/README.md index 8b1ec1e5ff..0fca481813 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,8 @@ Implementation of _Auxiliary Classifier Generative Adversarial Network_. Paper: https://arxiv.org/abs/1610.09585 +[Trained Model](https://app.wandb.ai/borisd13/Keras-GAN_AC-GAN/runs/tz46c8ow?workspace=user-borisd13) + #### Example ``` $ cd acgan/ @@ -79,6 +81,8 @@ Implementation of _Bidirectional Generative Adversarial Network_. Paper: https://arxiv.org/abs/1605.09782 +[Trained Model](https://app.wandb.ai/borisd13/Keras-BiGAN/runs/2b88b5vv?workspace=user-borisd13) + #### Example ``` $ cd bigan/ @@ -92,6 +96,8 @@ Implementation of _Boundary-Seeking Generative Adversarial Networks_. Paper: https://arxiv.org/abs/1702.08431 +[Trained Model](https://app.wandb.ai/borisd13/Keras-BGAN/runs/360cv3g4?workspace=user-borisd13) + #### Example ``` $ cd bgan/ diff --git a/acgan/acgan.py b/acgan/acgan.py index b9a5b24698..a2cc5c63c1 100755 --- a/acgan/acgan.py +++ b/acgan/acgan.py @@ -1,5 +1,6 @@ from __future__ import print_function, division +import wandb from keras.datasets import mnist from keras.layers import Input, Dense, Reshape, Flatten, Dropout, multiply from keras.layers import BatchNormalization, Activation, Embedding, ZeroPadding2D @@ -21,6 +22,16 @@ def __init__(self): self.img_shape = (self.img_rows, self.img_cols, self.channels) self.num_classes = 10 self.latent_dim = 100 + + # Log project run + wandb.init(anonymous='allow', + project="Keras-GAN_AC-GAN", + config={"img_rows": self.img_rows, + "img_cols": self.img_cols, + "channels": self.channels, + "img_shape": self.img_shape, + "num_classes": self.num_classes, + "latent_dim": self.latent_dim}) optimizer = Adam(0.0002, 0.5) losses = ['binary_crossentropy', 'sparse_categorical_crossentropy'] @@ -117,6 +128,9 @@ def build_discriminator(self): return Model(img, [validity, label]) def train(self, epochs, batch_size=128, sample_interval=50): + + # add extra parameters to log + wandb.config.update({"epochs": epochs, "batch_size": batch_size}) # Load the dataset (X_train, y_train), (_, _) = mnist.load_data() @@ -167,6 +181,9 @@ def train(self, epochs, batch_size=128, sample_interval=50): # Plot the progress print ("%d [D loss: %f, acc.: %.2f%%, op_acc: %.2f%%] [G loss: %f]" % (epoch, d_loss[0], 100*d_loss[3], 100*d_loss[4], g_loss[0])) + + # Log progress + wandb.log({'D loss': d_loss[0], 'acc': d_loss[3], 'op_acc': d_loss[4], 'G loss': g_loss[0]}, step=epoch) # If at save interval => save generated image samples if epoch % sample_interval == 0: @@ -188,6 +205,7 @@ def sample_images(self, epoch): axs[i,j].imshow(gen_imgs[cnt,:,:,0], cmap='gray') axs[i,j].axis('off') cnt += 1 + wandb.log({"images": fig}, step=epoch) fig.savefig("images/%d.png" % epoch) plt.close() diff --git a/bgan/bgan.py b/bgan/bgan.py index c891ccc7bb..41feea09f3 100644 --- a/bgan/bgan.py +++ b/bgan/bgan.py @@ -1,5 +1,6 @@ from __future__ import print_function, division +import wandb from keras.datasets import mnist from keras.layers import Input, Dense, Reshape, Flatten, Dropout from keras.layers import BatchNormalization, Activation, ZeroPadding2D @@ -24,6 +25,15 @@ def __init__(self): self.img_shape = (self.img_rows, self.img_cols, self.channels) self.latent_dim = 100 + # Log project run + wandb.init(anonymous='allow', + project="Keras-BGAN", + config={"img_rows": self.img_rows, + "img_cols": self.img_cols, + "channels": self.channels, + "img_shape": self.img_shape, + "latent_dim": self.latent_dim}) + optimizer = Adam(0.0002, 0.5) # Build and compile the discriminator @@ -139,6 +149,9 @@ def train(self, epochs, batch_size=128, sample_interval=50): # Plot the progress print ("%d [D loss: %f, acc.: %.2f%%] [G loss: %f]" % (epoch, d_loss[0], 100*d_loss[1], g_loss)) + + # Log progress + wandb.log({'D loss': d_loss[0], 'acc': d_loss[1], 'G loss': g_loss}, step=epoch) # If at save interval => save generated image samples if epoch % sample_interval == 0: @@ -158,6 +171,7 @@ def sample_images(self, epoch): axs[i,j].imshow(gen_imgs[cnt, :,:,0], cmap='gray') axs[i,j].axis('off') cnt += 1 + wandb.log({"images": fig}, step=epoch) fig.savefig("images/mnist_%d.png" % epoch) plt.close() diff --git a/bigan/bigan.py b/bigan/bigan.py index 61c837e7e4..a9a067ee5f 100644 --- a/bigan/bigan.py +++ b/bigan/bigan.py @@ -1,5 +1,6 @@ from __future__ import print_function, division +import wandb from keras.datasets import mnist from keras.layers import Input, Dense, Reshape, Flatten, Dropout, multiply, GaussianNoise from keras.layers import BatchNormalization, Activation, Embedding, ZeroPadding2D @@ -23,6 +24,15 @@ def __init__(self): self.channels = 1 self.img_shape = (self.img_rows, self.img_cols, self.channels) self.latent_dim = 100 + + # Log project run + wandb.init(anonymous='allow', + project="Keras-BiGAN", + config={"img_rows": self.img_rows, + "img_cols": self.img_cols, + "channels": self.channels, + "img_shape": self.img_shape, + "latent_dim": self.latent_dim}) optimizer = Adam(0.0002, 0.5) @@ -119,6 +129,9 @@ def build_discriminator(self): def train(self, epochs, batch_size=128, sample_interval=50): + # add extra parameters to log + wandb.config.update({"epochs": epochs, "batch_size": batch_size}) + # Load the dataset (X_train, _), (_, _) = mnist.load_data() @@ -160,6 +173,9 @@ def train(self, epochs, batch_size=128, sample_interval=50): # Plot the progress print ("%d [D loss: %f, acc: %.2f%%] [G loss: %f]" % (epoch, d_loss[0], 100*d_loss[1], g_loss[0])) + + # Log progress + wandb.log({'D loss': d_loss[0], 'acc': d_loss[1], 'G loss': g_loss[0]}, step=epoch) # If at save interval => save generated image samples if epoch % sample_interval == 0: @@ -179,6 +195,7 @@ def sample_interval(self, epoch): axs[i,j].imshow(gen_imgs[cnt, :,:,0], cmap='gray') axs[i,j].axis('off') cnt += 1 + wandb.log({"images": fig}, step=epoch) fig.savefig("images/mnist_%d.png" % epoch) plt.close() diff --git a/requirements.txt b/requirements.txt index 9ed28c8f39..4e0cacf29f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,6 +4,7 @@ matplotlib numpy scipy pillow +wandb #urllib #skimage scikit-image