我使用生成对抗网络对五个类别进行分类,彩色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”是从哪里来的? 操作员损耗:
discriminatorSymbol = mx.sym.LogisticRegressionOutput(data = fl5, label = label, name = 'dloss')
我从example中获取了所有信息。一切都在那里工作。
答案 0 :(得分:0)
此example中的GAN期望输入为(batch_size,channels,64、64),但您的数据为(64、3、128、128)。因此,由于形状识别器的输出是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