GAN 结构概览
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
生成对抗网络 (GAN) 由以下两个部分组成:
- 生成器会学习生成合理的数据。生成的实例会成为分类器的负例训练示例。
- 判别器会学习区分生成器的虚假数据与真实数据。如果生成器生成不可信的结果,判别器会对其进行惩罚。
训练开始时,生成器会生成明显虚假的数据,而判别器会快速学会判断这些数据是虚假的:

随着训练的进行,生成器越来越接近生成能够欺骗判别器的输出:

最后,如果生成器训练顺利,鉴别器就越难区分真实和虚假。它会开始将虚假数据归类为真实数据,准确性也会降低。

下面是整个系统的图片:

生成器和判别器都是神经网络。生成器输出直接连接到判别器输入。通过反向传播,分类器的分类会提供一个信号,用于生成器更新其权重。
下面我们来详细介绍一下该系统的各个部分。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-02-26。
[null,null,["最后更新时间 (UTC):2025-02-26。"],[[["\u003cp\u003eGANs consist of two neural networks: a generator creating data and a discriminator evaluating its authenticity.\u003c/p\u003e\n"],["\u003cp\u003eThe generator and discriminator are trained against each other, with the generator aiming to produce realistic data and the discriminator aiming to identify fake data.\u003c/p\u003e\n"],["\u003cp\u003eThrough continuous training, the generator improves its ability to create realistic data, while the discriminator struggles more with differentiation.\u003c/p\u003e\n"],["\u003cp\u003eThe ultimate goal is for the generator to create data so realistic that the discriminator cannot distinguish it from real data.\u003c/p\u003e\n"]]],[],null,["# Overview of GAN Structure\n\n\u003cbr /\u003e\n\nA generative adversarial network (GAN) has two parts:\n\n- The **generator** learns to generate plausible data. The generated instances become negative training examples for the discriminator.\n- The **discriminator** learns to distinguish the generator's fake data from real data. The discriminator penalizes the generator for producing implausible results.\n\nWhen training begins, the generator produces obviously fake data, and the\ndiscriminator quickly learns to tell that it's fake:\n\nAs training progresses, the generator gets closer to producing output that\ncan fool the discriminator:\n\nFinally, if generator training goes well, the discriminator gets worse at\ntelling the difference between real and fake. It starts to classify fake data as\nreal, and its accuracy decreases.\n\nHere's a picture of the whole system:\n\nBoth the generator and the discriminator are neural networks. The generator\noutput is connected directly to the discriminator input. Through\n[backpropagation](/machine-learning/glossary#backpropagation), the\ndiscriminator's classification provides a signal that the generator uses to\nupdate its weights.\n\nLet's explain the pieces of this system in greater detail."]]