我尝试运行一个类似于Keras documantation "VGG-like convnet"中的CNN,但是它是一个自定义的图像集和二进制分类,而不是10个类的输出。在
当我试图适应CNN时,我得到了一个冗长的错误,我认为这是告诉我我的输入图像大小不是适合CNN输入的大小。在
ValueError: GpuDnnConv images and kernel must have the same stack size
Apply node that caused the error: GpuDnnConv{algo='small', inplace=True}(GpuContiguous.0, GpuContiguous.0, GpuAllocEmpty.0, GpuDnnConvDesc{border_mode='valid', subsample=(1, 1), conv_mode='conv', precision='float32'}.0, Constant{1.0}, Constant{0.0})
Toposort index: 130
Inputs types: [CudaNdarrayType(float32, 4D), CudaNdarrayType(float32, 4D), CudaNdarrayType(float32, 4D), <theano.gof.type.CDataType object at 0x7f0eefc8d790>, Scalar(float32), Scalar(float32)]
Inputs shapes: [(32, 232, 300, 3), (300, 1, 3, 3), (32, 300, 298, 1), 'No shapes', (), ()]
Inputs strides: [(208800, 900, 3, 1), (9, 0, 3, 1), (89400, 298, 1, 0), 'No strides', (), ()]
Inputs values: ['not shown', 'not shown', 'not shown', <PyCObject object at 0x7f0efaba8e68>, 1.0, 0.0]
Inputs name: ('image', 'kernel', 'output', 'descriptor', 'alpha', 'beta')
问题是我认为我重新塑造了我所有的形象。我的输入是4000个232x300 px RBG图像的堆栈,输出是4000个布尔值的数组。在
输入:im_list.shape
Out[49]: (4000, 232, 300, 3)
输出:np.asarray(cls).shape
Out[50]: (4000,)
这是建立CNN的功能
^{pr2}$我的头撞到墙上的时间太长了,我想可能是别人有这个问题。有什么想法吗?提前谢谢。在
您将输入指定为
(depth,width,height)
。所以数组必须有(N,depth,width,height)
维,其中N是训练示例的数量。在实际传递的输入
(4000, 232, 300, 3)
不匹配。它应该被重塑成(4000, depth, width, height)
。这意味着您必须调整每个图像的大小,并重新排列轴。在上面的回答是正确的:对后人来说,我的问题是用一个简单的方法解决的:
相关问题 更多 >
编程相关推荐