我有一个生成的对抗网络,在这种网络中,鉴频器被MSE最小化,生成器应该得到最大化。因为他们都是追求相反目标的对手。
generator = Sequential()
generator.add(Dense(units=50, activation='sigmoid', input_shape=(15,)))
generator.add(Dense(units=1, activation='sigmoid'))
generator.compile(loss='mse', optimizer='adam')
generator.train_on_batch(x_data, y_data)
我需要适应什么,才能得到一个从高MSE值中获利的发电机模型?
这个问题我不太清楚。我想你想最大化而不是最小化,同时使用最小均方误差准则。在
您可以实现自己的自定义损耗函数,该函数计算-MSE;翻转损耗符号,从而实现梯度下降方向的翻转。在
另一个选择是简单地提供一个消极的学习步骤-但我不确定Keras是否允许您这样做。值得一试。在
更新:
原始的MSE实现如下所示:
我认为正确的最大化损失函数:
^{pr2}$这样我们总是得到一个正的损耗值,就像MSE函数的情况一样,但是有相反的效果。在
更新2: 最初我写道,由于优化方法的基本概念(您可以阅读一篇有趣的讨论here),简单地否定损失的直觉第一思想将而不是给出我们预期的结果(您可以阅读一篇有趣的讨论here)。 在我仔细检查了两种方法在特定学习任务中的结果后(注意:我没有做全面测试),两种方法都给出了损失最大化,尽管
-loss
方法收敛得更快。我不确定它是否总是给出最佳解决方案或任何解决方案,因为所描述的可能问题是here。 如果有人有其他经验,请告诉我。在因此,如果有人想尝试一下
^{3}$-loss
也:其他详细信息:
作者写道:
来自Ibragil提供的链接:
所以这是一个不适定问题:
在GAN中,我们的最终目标是训练我们的两个对手,即鉴别器和发生器尽可能地相互竞争。这意味着,两种基学习算法的任务不同,但获得最优解的损失函数是相同的,即
binary_crossentropy
,因此模型的任务是使损失最小化。在A鉴别器模型的编译方法:
A生成器模型的编译方法:
这就像两个跑步者的目标一样,尽可能缩短到达终点的时间,即使他们是这项任务的竞争对手。在
所以“相反的目标”并不意味着相反的任务,即最小化损失(即在跑步者示例中最小化时间)。
我希望有帮助。在
相关问题 更多 >
编程相关推荐