我使用生成对抗性网络对五类图像进行分类,颜色为128x128像素,批量大小为64。创建鉴别器模块时,执行时
discriminator.bind(data_shapes = image_iter.provide_data, label_shapes = [('label', (batch_size, ))], inputs_need_grad = True)
我得到一个错误:
data: (64, 3, 128, 128)
label: (64,)
Error in operator dloss: Shape inconsistent, Provided=[64], inferred shape=[64,25]
我不明白"25"这个数字是从哪里来的?操作员dloss:
discriminatorSymbol = mx.sym.LogisticRegressionOutput(data = fl5, label = label, name = 'dloss')
我从这个例子中得到了所有的信息。一切都在那里工作。
本例中的GAN期望输入为(batch_size,channels,64,64(,但您的数据为(64,31128128(。所以你会得到形状不匹配,因为鉴别器的输出是25而不是1。
print( mx.visualization.print_summary(discriminatorSymbol, shape={'data':(64,3,128,128)})) gives
Layer (type) Output Shape Param # Previous Layer
========================================================================================================================
data(null) 3x128x128 0
________________________________________________________________________________________________________________________
d1(Convolution) 128x64x64 6144 data
________________________________________________________________________________________________________________________
dact1(LeakyReLU) 128x64x64 0 d1
________________________________________________________________________________________________________________________
d2(Convolution) 256x32x32 524288 dact1
________________________________________________________________________________________________________________________
dbn2(BatchNorm) 256x32x32 512 d2
________________________________________________________________________________________________________________________
dact2(LeakyReLU) 256x32x32 0 dbn2
________________________________________________________________________________________________________________________
d3(Convolution) 512x16x16 2097152 dact2
________________________________________________________________________________________________________________________
dbn3(BatchNorm) 512x16x16 1024 d3
________________________________________________________________________________________________________________________
dact3(LeakyReLU) 512x16x16 0 dbn3
________________________________________________________________________________________________________________________
d4(Convolution) 1024x8x8 8388608 dact3
________________________________________________________________________________________________________________________
dbn4(BatchNorm) 1024x8x8 2048 d4
________________________________________________________________________________________________________________________
dact4(LeakyReLU) 1024x8x8 0 dbn4
________________________________________________________________________________________________________________________
d5(Convolution) 1x5x5 16384 dact4
________________________________________________________________________________________________________________________
flatten0(Flatten) 25 0 d5