GAN 只因为种子分布而在一批中生成完全相同的图像,为什么?

2024-04-05

I have trained a GAN to reproduce CIFAR10 like images. Initially I notice all images cross one batch produced by the generator look always the same, like the picture below: enter image description here

After hours of debugging and comparison to the tutorial which is a great learning source for beginners (https://machinelearningmastery.com/how-to-develop-a-generative-adversarial-network-for-a-cifar-10-small-object-photographs-from-scratch/ https://machinelearningmastery.com/how-to-develop-a-generative-adversarial-network-for-a-cifar-10-small-object-photographs-from-scratch/), I just add only one letter on my original code and the generated images start looking normal (everyone starts looking different from each other cross one batch), like the picture below: enter image description here

代码上神奇的一个字符更改是进行以下更改:

更改自:

def generate_latent_points(self, n_samples):
        return np.random.rand(n_samples, self.latent_dim)

to:

def generate_latent_points(self, n_samples):
        return np.random.randn(n_samples, self.latent_dim)

希望这个非常微妙的细节可以帮助那些花费数小时绞尽脑汁进行 GAN 训练过程的人。

np.random.rand给出均匀分布[0, 1)

np.random.randn给出均值 0 和方差 1 的单变量“正态”(高斯)分布

那么,为什么生成器的潜在种子分布差异会表现得如此不同呢?


我能想到的可能原因有以下几个:

  1. 这两者的分布差异有两个方面:1.rand只给出正值,而randn给出周围的负值和正值0; 2. rand给出的值大于randn原因显而易见。较大的幅度可能会导致学习不稳定,因为 dL/dw(与 x 成正比)将大于randn.

  2. 生成器的不成功学习对判别器区分真假图像没有任何挑战,因此判别器没有学习任何新东西。 (这是我在训练过程中对判别器的loss和acc的观察)

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

GAN 只因为种子分布而在一批中生成完全相同的图像,为什么? 的相关文章

随机推荐