我调整了DCGAN-Tensorflow code,将其鉴别器架构更改为non-convolutional net。这使得鉴别器和发生器损失从学习开始就开始并行,如下所示: 两种损失的数量都不是恒定的,它们会反弹,但非常轻微。生成的输出根本不好 - 模型似乎没有学习。
问题:之前有没有人遇到这样的事情?可能是什么问题?
完整的git存储库可用here。
这是编辑的鉴别器的代码,它破坏了代码:
def discriminator(self, image, y=None, reuse=False):
with tf.variable_scope("discriminator") as scope:
if reuse:
scope.reuse_variables()
if not self.y_dim:
im = tf.reshape(image, [64, 160])
self.h0, self.h0_w, self.h0_b = linear(im, 1024, 'd_h0', with_w = True)
h0 = tf.nn.tanh(self.g_bn0(self.h0))
self.h1, self.h1_w, self.h1_b = linear(h0, 1024, 'd_h1', with_w = True)
h1 = tf.nn.tanh(self.g_bn1(self.h1))
self.h2, self.h2_w, self.h2_b = linear(h1, 160, 'd_h2', with_w = True)
h2 = tf.nn.tanh(self.g_bn2(self.h2))
self.h3, self.h3_w, self.h3_b = linear(h2, 2, 'd_h3', with_w = True)
h3 = tf.nn.tanh(self.g_bn3(self.h3))
h4 = linear(tf.reshape(h3, [self.batch_size, -1]), 1, 'd_h4')
return tf.nn.sigmoid(h4), h4
而不是原来的那个:
def discriminator(self, image, y=None, reuse=False):
with tf.variable_scope("discriminator") as scope:
if reuse:
scope.reuse_variables()
if not self.y_dim:
h0 = lrelu(conv2d(image, self.df_dim, name='d_h0_conv'))
h1 = lrelu(self.d_bn1(conv2d(h0, self.df_dim*2, name='d_h1_conv')))
h2 = lrelu(self.d_bn2(conv2d(h1, self.df_dim*4, name='d_h2_conv')))
h3 = lrelu(self.d_bn3(conv2d(h2, self.df_dim*8, name='d_h3_conv')))
h4 = linear(tf.reshape(h3, [self.batch_size, -1]), 1, 'd_h3_lin')
return tf.nn.sigmoid(h4), h4