Created
February 24, 2020 16:32
-
-
Save Bornlex/5797bb11582a94b5ed4edc6927b8aa9e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| LATENT_SIZE = 16 | |
| adam = keras.optimizers.Adam(lr=0.0002, beta_1=0.5) | |
| with tf.device("/gpu:0"): | |
| input_x_img = keras.layers.Input((784,)) | |
| x = keras.layers.Dense(1024, activation="relu")(input_x_img) | |
| x = keras.layers.Dense(256, activation="relu")(x) | |
| x = keras.layers.Dense(1, activation="sigmoid")(x) | |
| discriminator = keras.models.Model(inputs=input_x_img, outputs=x) | |
| discriminator.compile(optimizer=adam, loss="binary_crossentropy") | |
| input_x_latent = keras.layers.Input((LATENT_SIZE,)) | |
| x = keras.layers.Dense(256, activation="relu")(input_x_latent) | |
| x = keras.layers.Dense(1024, activation="relu")(x) | |
| x = keras.layers.Dense(784, activation="tanh")(x) | |
| generator = keras.models.Model(inputs=input_x_latent, outputs=x) | |
| generator.compile(optimizer=adam, loss="binary_crossentropy") | |
| discriminator.trainable = False | |
| gan_input = keras.layers.Input((LATENT_SIZE,)) | |
| x = generator(gan_input) | |
| gan_output = discriminator(x) | |
| gan = keras.models.Model(inputs=gan_input, outputs=gan_output) | |
| gan.compile(optimizer=adam, loss="binary_crossentropy") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment