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.

Improved GANs

Essentially, in CGAN we feed the network with side information (label). In ACGAN,

we try to reconstruct the side information using an auxiliary class decoder network.

ACGAN argued that forcing the network to do additional tasks is known to improve

the performance of the original task. In this case, the additional task is image

classification. The original task is the generation of fake images.

Network Loss Functions Number

CGAN ( D)

L =−E

x~ p

log D( x | y) −Ez

log 1 −D D( z | y)

L

( G)

data

=−E z

log D( G( z | y)

)

( ( ))

ACGAN ( D)

L =−E log D( x) −E log 1 −D( G ( z | y)

) −E log P c | x −E

log P ( c | G z | y )

( ) ( ) ( )

x~ pdata

z x~

pdata

z

( G)

L =−E

log D( G( z | y)

) −E

log P ( c | G( z | y)

)

z

z

4.3.1

4.3.2

5.3.1

5.3.2

Table 5.3.1: A comparison between the loss functions of CGAN and ACGAN

Preceding table shows the ACGAN loss functions as compared to CGAN.

The ACGAN loss functions are the same as CGAN except for the additional

classifier loss functions. Apart from the original task of identifying real from fake

images ( −E

x~ p

log D( x | y) −E

log( 1 ( ( | )))

data

z

−D G z y ), Equation 5.3.1 of the discriminator

has the additional task of correctly classifying real and fake images

( −E

x~ p

log P ( c | x) −E

log ( | ( | ))

data

z

P c G z y ). Equation 5.3.2 of the generator

means that apart from trying to fool the discriminator with fake images

( −E

z

log D( G ( z | y)

)), it is asking the discriminator to correctly classify those

fake images ( −E

z

log P ( c | G ( z | y)

) ).

Starting with the CGAN code, only the discriminator and the training function are

modified to implement ACGAN. The discriminator and generator builder functions

are also provided by gan.py. To see the changes made on the discriminator,

following listing shows the builder function where the auxiliary decoder network

that performs image classification and the dual outputs are highlighted.

Listing 5.3.1, gan.py shows how the discriminator model builder is the same as

in DCGAN predicting if an image is real, the first output. An auxiliary decoder

network is added to perform the image classification and produce the second output:

def discriminator(inputs,

activation='sigmoid',

num_labels=None,

num_codes=None):

"""Build a Discriminator Model

[ 148 ]

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

Saved successfully!

Ooh no, something went wrong!