如何在 GAN 判别器中对另一个损失函数进行分类?
我对 GAN 很感兴趣。 我尝试通过以下方法调整DCGAN的判别器: https://github.com/vasily789/adaptive-weighted-甘斯/blob/main/aw_loss.py 哪个名称是 aw 方法。 所以我在kaggle中找到了一个DCGAN代码(https://www.kaggle .com/vatsalmavani/deep-convolutional-gan-in-pytorch)并尝试按 aw_loss 类编辑判别器。
这是我的代码:
https://colab.research.google.com/drive/1AsZztd0Af0UMzBXXkI9QKQZhAUoK01bk?usp=sharing
看来我无法正确分类 aw 损失。因为我训练的时候判别器的loss还是0。 任何人都可以帮助我。请!
I am a interested in GAN.
I tried to adjust the DCGAN's discriminator by this method below:
https://github.com/vasily789/adaptive-weighted-gans/blob/main/aw_loss.py
which name is aw method.
So I find a DCGAN code in kaggle(https://www.kaggle.com/vatsalmavani/deep-convolutional-gan-in-pytorch) and try to edit the discriminator by class the aw_loss.
Here is my code:
https://colab.research.google.com/drive/1AsZztd0Af0UMzBXXkI9QKQZhAUoK01bk?usp=sharing
it seems like I can not class the aw loss correctly. Because the discriminator's loss is still 0 when I training.
Any one can help me. Please!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在您提供的代码中,在尝试使用
aw_method()
时,它确实显示了正确的错误,您应该首先实例化该类,如下所示,然后您应该能够调用该方法。请注意,我们使用类的默认参数,不太熟悉 aw loss 来告诉您是否应该调整它。
关于鉴别器的损失,正确的代码依赖于
aw_cost
来工作。看起来你并没有同时提供真实和虚假的损失,因此鉴别器只是学习输出 1 或 0(可以通过打印这些值或使用 wandb 或类似工具进行监控来轻松验证)。再次没有足够深入地了解 aw 损失的算法,因此请具体检查这一点。也可以尝试将正常
D_loss = (D_fake_loss + D_real_loss + aw_loss) / 3 的线性组合进行测试。
In the code you provided, it does display the correct error when trying to use
aw_method()
, you should first instance the class as shown below after which you should be able to call the method.Notice that we are using default parameters for the class, not so familiar with aw loss to tell you if you should tweak that.
Regarding your discriminator's loss, correct code relies on
aw_cost
to work. It doesn't seem like your providing both losses from real and fake, so the discriminator is only learning to output 1's or 0's (which can be easily verified by printing those values or monitoring with wandb or similar tools). Again didn't go deep enough into the algorithm of the aw loss, so check this specifically.Also could try to test as a linear combination of your normal
D_loss = (D_fake_loss + D_real_loss + aw_loss) / 3
.