常见问题
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
GAN 存在多种常见的失败模式。所有这些常见问题都是我们正在积极研究的领域。虽然这些问题都尚未得到彻底解决,但我们会介绍一些用户尝试过的方法。
消失的渐变
研究表明,如果判别器过于出色,生成器训练可能会因梯度消失而失败。实际上,最佳判别器无法为生成器提供足够的信息来取得进展。
尝试解决问题
模式收起
通常,您希望 GAN 生成各种各样的输出。例如,您希望为面部生成器的每个随机输入生成不同的面孔。
不过,如果生成器生成的输出特别可信,则可能会学到仅生成该输出。事实上,生成器始终在尝试找到对判别器而言最合理的输出。
如果生成器开始反复生成相同的输出(或一小组输出),鉴别器的最佳策略是学习始终拒绝该输出。但是,如果下一代分类器陷入局部最小值而未找到最佳策略,那么下一次生成器迭代就很容易为当前分类器找到最合理的输出。
生成器的每次迭代都会针对特定的鉴别器过度优化,而鉴别器永远无法学会摆脱陷阱。因此,生成器会轮替使用一小部分输出类型。这种形式的 GAN 失败称为“模式崩溃”。
尝试解决问题
以下方法会尝试阻止生成器针对单个固定的鉴别器进行优化,从而迫使生成器扩大其范围:
- Wasserstein 损失:Wasserstein 损失可让您将分类器训练到最优状态,而无需担心梯度消失,从而缓解模式崩溃问题。如果鉴别器不会卡在局部极小值,则会学习拒绝生成器稳定下来的输出。因此,生成器必须尝试新的方法。
- 展开式 GAN:展开式 GAN 使用生成器损失函数,该函数不仅包含当前分类器的分类,还包含未来分类器版本的输出。因此,生成器无法针对单个判别器过度优化。
未能收敛
GAN 经常无法收敛,如训练模块中所述。
尝试采取补救措施
研究人员尝试过使用各种形式的正则化来提高 GAN 的收敛性,包括:
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-02-26。
[null,null,["最后更新时间 (UTC):2025-02-26。"],[[["\u003cp\u003eGANs suffer from common failure modes like vanishing gradients, mode collapse, and failure to converge, all of which are areas of active research.\u003c/p\u003e\n"],["\u003cp\u003eVanishing gradients occur when a discriminator becomes too good, hindering the generator's progress, and can be addressed with techniques like Wasserstein loss or modified minimax loss.\u003c/p\u003e\n"],["\u003cp\u003eMode collapse happens when a generator repeatedly produces the same or similar outputs, and solutions include using Wasserstein loss or unrolled GANs to encourage output diversity.\u003c/p\u003e\n"],["\u003cp\u003eFailure to converge is a common issue, and researchers are exploring regularization methods such as adding noise to discriminator inputs or penalizing discriminator weights to improve stability.\u003c/p\u003e\n"]]],[],null,["# Common Problems\n\nGANs have a number of common failure modes. All of these common problems are\nareas of active research. While none of these problems have been completely\nsolved, we'll mention some things that people have tried.\n\nVanishing Gradients\n-------------------\n\n[Research](https://arxiv.org/pdf/1701.04862.pdf) has suggested that if your\ndiscriminator is too good, then generator training can fail due to [vanishing\ngradients](https://wikipedia.org/wiki/Vanishing_gradient_problem). In effect,\nan optimal discriminator doesn't provide enough information for the generator to\nmake progress.\n\n### Attempts to Remedy\n\n- **Wasserstein loss** : The [Wasserstein loss](/machine-learning/gan/loss) is designed to prevent vanishing gradients even when you train the discriminator to optimality.\n- **Modified minimax loss** : The [original GAN\n paper](http://papers.nips.cc/paper/5423-generative-adversarial-nets.pdf) proposed a [modification to minimax loss](/machine-learning/gan/loss) to deal with vanishing gradients.\n\nMode Collapse\n-------------\n\nUsually you want your GAN to produce a wide variety of outputs. You want, for\nexample, a different face for every random input to your face generator.\n\nHowever, if a generator produces an especially plausible output, the generator\nmay learn to produce *only* that output. In fact, the generator is always trying\nto find the one output that seems most plausible to the discriminator.\n\nIf the generator starts producing the same output (or a small\nset of outputs) over and over again, the discriminator's best\nstrategy is to learn to always reject that output. But if the next\ngeneration of discriminator gets stuck in a local minimum and doesn't find the\nbest strategy, then it's too easy for the next generator iteration to find the\nmost plausible output for the current discriminator.\n\nEach iteration of generator over-optimizes for a particular discriminator, and\nthe discriminator never manages to learn its way out of the trap. As a result\nthe generators rotate through a small set of output types. This form of GAN\nfailure is called **mode collapse**.\n\n### Attempts to Remedy\n\nThe following approaches try to force the generator to broaden its scope by\npreventing it from optimizing for a single fixed discriminator:\n\n- **Wasserstein loss** : The [Wasserstein loss](/machine-learning/gan/loss) alleviates mode collapse by letting you train the discriminator to optimality without worrying about vanishing gradients. If the discriminator doesn't get stuck in local minima, it learns to reject the outputs that the generator stabilizes on. So the generator has to try something new.\n- **Unrolled GANs** : [Unrolled GANs](https://arxiv.org/pdf/1611.02163.pdf) use a generator loss function that incorporates not only the current discriminator's classifications, but also the outputs of future discriminator versions. So the generator can't over-optimize for a single discriminator.\n\nFailure to Converge\n-------------------\n\nGANs frequently fail to converge, as discussed in the module on\n[training](/machine-learning/gan/training).\n\n### Attempts to Remedy\n\nResearchers have tried to use various forms of regularization to improve GAN\nconvergence, including:\n\n- **Adding noise to discriminator inputs** : See, for example, [Toward Principled\n Methods for Training Generative Adversarial\n Networks](https://arxiv.org/pdf/1701.04862.pdf).\n- **Penalizing discriminator weights** : See, for example, [Stabilizing Training\n of Generative Adversarial Networks through\n Regularization](https://arxiv.org/pdf/1705.09367.pdf)."]]