我训练了一个生成对抗网络来实现图像到图像的翻译任务。我用WassersteinGAN训练了带有如下代码的梯度罚分的模型。但是,如图所示,在网络训练过程中,我发现发电机的损耗将变为负值,并在正负之间变化。这是正常现象吗?
gen_loss_GAN = -tf.reduce_mean(dis_fake)
gen_loss_L1 = tf.reduce_mean(l1_loss(gen_label, train_label))
gen_loss = gen_loss_GAN * args.lamda_gan_weight + gen_loss_L1 * args.lamda_l1_weight #the total generator loss
eps = tf.random_uniform([1, 1], minval=0., maxval=1.)
X_inter = eps*train_label + (1. - eps)*gen_label
grad = tf.gradients(discriminator(image=concat_image, targets=X_inter, reuse=True), [X_inter])[0]
print(grad)
grad_norm = tf.sqrt(tf.reduce_sum((grad)**2, axis=1))
grad_pen = 10 * tf.reduce_mean((grad_norm - 1.)**2)
dis_loss = -tf.reduce_mean(dis_real)+tf.reduce_mean(dis_fake)+grad_pen #the total discriminator loss