Gans 中生成器的损失函数
Loss Function of generator in Gans
-
artificial-intelligence
-
machine-learning
-
computer-vision
-
conv-neural-network
-
generative-adversarial-network
我深入研究了gans,也在pytorch中实现了它,现在正在研究gans背后的核心统计,当时我正在看那个网站Mathematics behing Gans
它说
"Loss(G) = - Loss(D), Notice that we defined the generators cost as negative of discriminator’s cost. This is because we do not have an explicit way to evaluate a generator’s cost."
但是当实现 gan 时,我们将生成器的损失定义为:
Bintropy Cross entropy loss between the discriminator output for the images produced by generator and Real labels as in the Original Paper and following code (implemented and tested by me)
# train generator
z_ = to.randn(minibatch,100 ).view(-1, 100, 1, 1)
z_ = Variable(z_.cuda())
gen_images = generator(z_)
D_fake_decisions = discriminator(gen_images).squeeze()
G_loss = criterion(D_fake_decisions,real_labels)
discriminator.zero_grad()
generator.zero_grad()
G_loss.backward()
opt_Gen.step()
请解释一下两者的区别,正确的
代码 Link : https://github.com/mabdullahrafique/Gan_with_Pytorch/blob/master/DCGan_mnist.ipynb
谢谢
判别器的工作是进行二元分类来检测真假,所以它的损失函数是二元交叉熵。
Generator 做的是 Density Estimation,从噪声到真实数据,然后喂给 Discriminator 来糊弄它。
设计中遵循的方法是将其建模为MinMax游戏。现在让我们来看看成本函数:
有人解释为:
The first term in J(D) represents feeding the actual data to the discriminator, and the discriminator would want to maximize the log probability of predicting one, indicating that the data is real. The second term represents the samples generated by G. Here, the discriminator would want to maximize the log probability of predicting zero, indicating the the data is fake. The generator, on the other hand tries to minimize the log probability of the discriminator being correct. The solution to this problem is an equilibrium point of the game, which is a saddle point of the discriminator loss.
由于判别器试图最大化生成器样本为零的概率,生成器的工作变成了最大化一个。这相当于使生成器的成本函数成为负交叉熵,其中 J(D) 中的第一项现在将是常数。
来源:https://towardsdatascience.com/generative-adversarial-networks-history-and-overview-7effbb713545
artificial-intelligence
machine-learning
computer-vision
conv-neural-network
generative-adversarial-network
我深入研究了gans,也在pytorch中实现了它,现在正在研究gans背后的核心统计,当时我正在看那个网站Mathematics behing Gans 它说
"Loss(G) = - Loss(D), Notice that we defined the generators cost as negative of discriminator’s cost. This is because we do not have an explicit way to evaluate a generator’s cost."
但是当实现 gan 时,我们将生成器的损失定义为:
Bintropy Cross entropy loss between the discriminator output for the images produced by generator and Real labels as in the Original Paper and following code (implemented and tested by me)
# train generator
z_ = to.randn(minibatch,100 ).view(-1, 100, 1, 1)
z_ = Variable(z_.cuda())
gen_images = generator(z_)
D_fake_decisions = discriminator(gen_images).squeeze()
G_loss = criterion(D_fake_decisions,real_labels)
discriminator.zero_grad()
generator.zero_grad()
G_loss.backward()
opt_Gen.step()
请解释一下两者的区别,正确的
代码 Link : https://github.com/mabdullahrafique/Gan_with_Pytorch/blob/master/DCGan_mnist.ipynb
谢谢
判别器的工作是进行二元分类来检测真假,所以它的损失函数是二元交叉熵。
Generator 做的是 Density Estimation,从噪声到真实数据,然后喂给 Discriminator 来糊弄它。
设计中遵循的方法是将其建模为MinMax游戏。现在让我们来看看成本函数:
有人解释为:
The first term in J(D) represents feeding the actual data to the discriminator, and the discriminator would want to maximize the log probability of predicting one, indicating that the data is real. The second term represents the samples generated by G. Here, the discriminator would want to maximize the log probability of predicting zero, indicating the the data is fake. The generator, on the other hand tries to minimize the log probability of the discriminator being correct. The solution to this problem is an equilibrium point of the game, which is a saddle point of the discriminator loss.
由于判别器试图最大化生成器样本为零的概率,生成器的工作变成了最大化一个。这相当于使生成器的成本函数成为负交叉熵,其中 J(D) 中的第一项现在将是常数。
来源:https://towardsdatascience.com/generative-adversarial-networks-history-and-overview-7effbb713545