16.03.2021 Views

Advanced Deep Learning with Keras

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 6

Figure 6.2.8: A StackedGAN Discriminator model in Keras

Listing 6.2.3, stackedgan-mnist-6.2.1.py shows the Discriminator 1

implementation

in Keras:

def build_discriminator(inputs, z_dim=50):

"""Build Discriminator 1 Model

Classifies feature1 (features) as real/fake image and recovers

the input noise or latent code (by minimizing entropy loss)

# Arguments

inputs (Layer): feature1

z_dim (int): noise dimensionality

# Returns

dis1 (Model): feature1 as real/fake and recovered latent code

"""

# input is 256-dim feature1

x = Dense(256, activation='relu')(inputs)

x = Dense(256, activation='relu')(x)

[ 189 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!