【问题标题】:Keras GAN with multiple output from generator and discriminator respectively分别来自生成器和鉴别器的多个输出的 Keras GAN
【发布时间】:2019-04-01 01:55:43
【问题描述】:

我正在使用 Keras 对 GAN 进行建模,我需要结合两个损失,因为我有两个输出。一个输出来自 Discriminator,在下面的代码中表示为“label”,另一个来自 Generator,表示为“Bloss”。那么是否可以分别用 G 和 D 的两个输出来训练 GAN(组合生成器和判别器)的组合模型?

    input = Input(shape=self.input_shape)
    output_G, Bloss = self.G(input)

    # For the combined model we will only train the generator
    self.D.trainable = False

    label = self.D(output_G)

    self.combined = Model(inputs=input,
                          outputs=[label, Bloss])
    self.combined.compile(loss=['categorical_crossentropy', B_loss],
                          optimizer='RMSprop',
                          loss_weights=[1,0.01])
...
def B_loss(y_true, y_pred):
    return K.mean(y_pred - y_true, axis=-1)

【问题讨论】:

    标签: keras generative-adversarial-network


    【解决方案1】:

    我不明白为什么不这样做,只要您创建一个适当的 y 组合标签(D 输出)和 Bloss(部分 G 输出)。

    【讨论】:

      猜你喜欢
      • 2020-05-05
      • 2019-12-22
      • 2018-07-23
      • 2020-06-27
      • 1970-01-01
      • 2018-03-25
      • 1970-01-01
      • 2022-10-04
      • 2019-02-12
      相关资源
      最近更新 更多