Search code examples
loss-functionlossgenerative-adversarial-network

Why we use two losses while compiling the combined GAN (SRGAN) network


I m working on SRGAN (Super resolution GAN). and i came across a code, in which the author is using MSE loss while compiling Discriminator. and two losses i.e. binary-cross-entropy and MSE, while compiling combined GAN model. i don't understand the use of these loss function. here is the code. the code for compiling Discriminator is:

discriminator = build_discriminator()
discriminator.compile(loss='mse', optimizer=common_optimizer, metrics=['accuracy']

and the code for compiling combined GAN model is:

adversarial_model = Model([input_low_resolution, input_high_resolution], [probs, features])
adversarial_model.compile(loss=['binary_crossentropy', 'mse'], loss_weights=[1e-3, 1],
                      optimizer=common_optimizer)

one thing more.. that for the below line of code i get the output shown below. i don't understand what this output mean.

g_loss = adversarial_model.train_on_batch([low_resolution_images, high_resolution_images],
                                          [real_labels, image_features])

Result of the above mentioned code


Solution

  • If it is a fake image generated by the generator, MSE loss is performed with the real image. If it is a false image judged by the discriminator, use BCE loss.