我正在尝试在 CelebA 对齐数据集上使用生成对抗网络(GAN)生成图像,并将每个图像的大小调整为 .jpeg 格式的 64*64。我的网络定义是这样的
def my_discriminator(input_var= None):
net = lasagne.layers.InputLayer(shape= (None, 3,64,64), input_var = input_var)
net = lasagne.layers.Conv2DLayer(net, 64, filter_size= (6,6 ),stride = 2,pad=2,W = lasagne.init.HeUniform(), nonlinearity= lasagne.nonlinearities.LeakyRectify(0.2))#64*32*32
net = lasagne.layers.Conv2DLayer(net, 128, filter_size= (6,6),stride = 2,pad=2,W = lasagne.init.HeUniform(), nonlinearity= lasagne.nonlinearities.LeakyRectify(0.2))#128*16*16
net = lasagne.layers.Conv2DLayer(net, 256, filter_size= (6,6),stride = 2,pad=2,W = lasagne.init.HeUniform(), nonlinearity= lasagne.nonlinearities.LeakyRectify(0.2))#256*8*8
net = lasagne.layers.Conv2DLayer(net, 512, filter_size= (6,6),stride = 2,pad=2,W = lasagne.init.HeUniform(), nonlinearity= lasagne.nonlinearities.LeakyRectify(0.2))#512*4*4
net = lasagne.layers.DenseLayer(net, 2048, W= lasagne.init.HeUniform(), nonlinearity= lasagne.nonlinearities.LeakyRectify(0.2))
net = lasagne.layers.DenseLayer(net, 1, nonlinearity = lasagne.nonlinearities.sigmoid)
def my_generator(input_var=None):
gen_net = lasagne.layers.InputLayer(shape = (None, 100), input_var = input_var)
gen_net = lasagne.layers.DenseLayer(gen_net, 2048, W= lasagne.init.HeUniform())
gen_net = lasagne.layers.DenseLayer(gen_net, 512*4*4, W= lasagne.init.HeUniform())
gen_net = lasagne.layers.ReshapeLayer(gen_net, shape = ([0],512,4,4))
gen_net = lasagne.layers.Deconv2DLayer(gen_net, 256,filter_size= (6,6),stride = 2,crop=2, W= lasagne.init.HeUniform(), nonlinearity= lasagne.nonlinearities.rectify)
gen_net = lasagne.layers.Deconv2DLayer(gen_net, 128,filter_size= (6,6),stride = 2,crop=2, W= lasagne.init.HeUniform(), nonlinearity= lasagne.nonlinearities.rectify)
gen_net = lasagne.layers.Deconv2DLayer(gen_net, 64, filter_size= (6,6), stride=2,crop=2,W= lasagne.init.HeUniform(), nonlinearity= lasagne.nonlinearities.rectify)
gen_net = lasagne.layers.Deconv2DLayer(gen_net, 3, filter_size= (6,6),stride = 2,crop=2, nonlinearity= lasagne.nonlinearities.tanh)
通过生成器生成的图像,我得到了一些随机颜色的像素以及其中的“网格”结构,如示例图像所示:
我的问题是这两个问题的原因是什么,我也使用了几乎相同的架构,在 Cifar-10 数据集上的生成器和判别器中少了一个卷积层,具有 .png 格式的 32*32 分辨率图像,但生成的图像是不是这样的。不确定图像格式是否是原因。如果有人可以提供一些想法或方法或链接,我将非常感激,以摆脱这些问题。