Created
May 30, 2023 08:45
-
-
Save pythonlessons/0607c4e9281856cab86cd56a2285028a to your computer and use it in GitHub Desktop.
wgan_gp
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
| import tensorflow as tf | |
| from keras import layers | |
| # Define the discriminator model | |
| def build_discriminator(img_shape, activation='linear', alpha=0.2): | |
| inputs = layers.Input(shape=img_shape, name="input") | |
| x = layers.Conv2D(64, (5, 5), strides=(2, 2), padding='same', use_bias=False)(inputs) | |
| x = layers.LeakyReLU(alpha)(x) | |
| x = layers.Conv2D(128, (5, 5), strides=(2, 2), padding='same', use_bias=False)(x) | |
| x = layers.LeakyReLU(alpha)(x) | |
| x = layers.Conv2D(256, (5, 5), strides=(2, 2), padding='same', use_bias=False)(x) | |
| x = layers.LeakyReLU(alpha)(x) | |
| x = layers.Conv2D(512, (5, 5), strides=(2, 2), padding='same', use_bias=False)(x) | |
| x = layers.LeakyReLU(alpha)(x) | |
| x = layers.Flatten()(x) | |
| x = layers.Dropout(0.5)(x) | |
| x = layers.Dense(1, activation=activation, dtype='float32')(x) | |
| model = tf.keras.Model(inputs=inputs, outputs=x) | |
| return model |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment