text_plain_output_1.png
import keras as K

import numpy as np

import tensorflow as tf

np.random.seed(1)
tf.set_random_seed(1)

tf.logging.set_verbosity(tf.logging.ERROR)
discriminator = K.Sequential()
depth = 64
dropout = 0.4
input_shape = (28, 28, 1)
discriminator.add(K.layers.Conv2D(depth * 1, 5, strides=2, input_shape=input_shape, padding='same'))
discriminator.add(K.layers.LeakyReLU(alpha=0.2))
discriminator.add(K.layers.Dropout(dropout))
discriminator.add(K.layers.Conv2D(depth * 2, 5, strides=2, padding='same'))
discriminator.add(K.layers.LeakyReLU(alpha=0.2))
discriminator.add(K.layers.Dropout(dropout))
discriminator.add(K.layers.Conv2D(depth * 4, 5, strides=2, padding='same'))
discriminator.add(K.layers.LeakyReLU(alpha=0.2))
discriminator.add(K.layers.Dropout(dropout))
discriminator.add(K.layers.Conv2D(depth * 8, 5, strides=1, padding='same'))
discriminator.add(K.layers.LeakyReLU(alpha=0.2))
discriminator.add(K.layers.Dropout(dropout))
discriminator.add(K.layers.Flatten())
discriminator.add(K.layers.Dense(1, activation='sigmoid'))
discriminator.summary()

tf.logging.set_verbosity(tf.logging.ERROR)
generator = K.Sequential()
depth = 64 + 64 + 64 + 64
dim = 7
dropout = 0.4
generator.add(K.layers.Dense(dim * dim * depth, input_shape=(100,)))
generator.add(K.layers.BatchNormalization(momentum=0.9))
generator.add(K.layers.ReLU())
generator.add(K.layers.Reshape((dim, dim, depth)))
generator.add(K.layers.Dropout(dropout))
generator.add(K.layers.UpSampling2D())
generator.add(K.layers.Conv2DTranspose(int(depth / 2), 5, padding='same'))
generator.add(K.layers.BatchNormalization(momentum=0.9))
generator.add(K.layers.ReLU())
generator.add(K.layers.UpSampling2D())
generator.add(K.layers.Conv2DTranspose(int(depth / 4), 5, padding='same'))
generator.add(K.layers.BatchNormalization(momentum=0.9))
generator.add(K.layers.ReLU())
generator.add(K.layers.Conv2DTranspose(int(depth / 8), 5, padding='same'))
generator.add(K.layers.BatchNormalization(momentum=0.9))
generator.add(K.layers.ReLU())
generator.add(K.layers.Conv2DTranspose(1, 5, padding='same', activation='sigmoid'))
generator.summary()