aboutsummaryrefslogtreecommitdiff
path: root/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'models.py')
-rw-r--r--models.py37
1 files changed, 37 insertions, 0 deletions
diff --git a/models.py b/models.py
new file mode 100644
index 0000000..5a28b27
--- /dev/null
+++ b/models.py
@@ -0,0 +1,37 @@
+# models.py
+# EE4 Computer vision coursework: Models for GAN coursework
+from keras.models import Model, Sequential
+from keras.layers import *
+
+def get_generator:
+ generator = Sequential([
+ Dense(128*7*7, input_dim=100, activation=LeakyReLU(0.2)),
+ BatchNormalization(),
+ Reshape((7,7,128)),
+ UpSampling2D(),
+ Convolution2D(64, 5, 5, border_mode='same', activation=LeakyReLU(0.2)),
+ BatchNormalization(),
+ UpSampling2D(),
+ Convolution2D(1, 5, 5, border_mode='same', activation='tanh')
+ ])
+
+ discriminator = Sequential([
+ Convolution2D(64, 5, 5, subsample=(2,2), input_shape=(28,28,1), border_mode='same', activation=LeakyReLU(0.2)),
+ Dropout(0.3),
+ Convolution2D(128, 5, 5, subsample=(2,2), border_mode='same', activation=LeakyReLU(0.2)),
+ Dropout(0.3),
+ Flatten(),
+ Dense(1, activation='sigmoid')
+ ])
+ return generator
+
+def get_discriminator:
+ discriminator = Sequential([
+ Convolution2D(64, 5, 5, subsample=(2,2), input_shape=(28,28,1), border_mode='same', activation=LeakyReLU(0.2)),
+ Dropout(0.3),
+ Convolution2D(128, 5, 5, subsample=(2,2), border_mode='same', activation=LeakyReLU(0.2)),
+ Dropout(0.3),
+ Flatten(),
+ Dense(1, activation='sigmoid')
+ ])
+ return discriminator