-3

I'm now trying to implement GAN in keras. I want to use both the GAN loss and the generator loss at the same time when I train the network. Because I've found from some papers that this might contribute to some performance gain.

It is a little bit like the loss function in the paper 'Multi-Scale Video Frame-Synthesis Network with Transitive Consistency Loss': Loss function

The original code with the GAN loss alone is like the following:

self.generator = generator
self.discriminator = discriminator
self.gan = Sequential([generator, discriminator])
gen, dis, gendis = self.generator, self.discriminator, self.gan
gendis.compile(optimizer=opt, loss='binary_crossentropy')

I'd like to combine the generator loss together. Thus, I tried the following:

gendis.compile(optimizer=opt, loss={'generator_output': 'mse', 'model_2':'binary_crossentropy'}, loss_weights=[1., 0.2])

But it doesn't work and show the error message: ' ValueError: Unknown entry in loss dictionary: "generator_output". Only expected the following keys: ['model_2']'.

How can I add the generator loss into this training procedure?

Thanks a lot!

Queenie
  • 27
  • 1
  • 5

1 Answers1

1

You may need to set the key of the loss dict to the model output names. So if the second key was expected to be model_2 so maybe the first one is model_1? Can print out the model summary?

anj-s
  • 21
  • 2