mxnet中标签内存分配问题,python
The problem with the allocation of memory for labels in mxnet, python
我使用生成对抗网络对五个 类、颜色、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')
我从这个 example 中获取了所有信息。那里一切正常。
来自此 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
我使用生成对抗网络对五个 类、颜色、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')
我从这个 example 中获取了所有信息。那里一切正常。
来自此 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