aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVasil Zlatanov <v@skozl.com>2019-02-25 18:43:20 +0000
committerVasil Zlatanov <v@skozl.com>2019-02-25 18:43:20 +0000
commit69d462050a9a8514d48c8833400a42d8204c643c (patch)
tree52380267091413e500851e1ce910f100708086e5
parent786ed447081dd0866ee54f6753a72eeeccc301b5 (diff)
downloade4-gan-69d462050a9a8514d48c8833400a42d8204c643c.tar.gz
e4-gan-69d462050a9a8514d48c8833400a42d8204c643c.tar.bz2
e4-gan-69d462050a9a8514d48c8833400a42d8204c643c.zip
Add basic models for DCGAN
-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