【发布时间】:2019-08-14 06:48:23
【问题描述】:
我有维度为24*64*64*10的数据(不包括批量大小)。
我想将输入拆分为 24 个维度为 64*64*10 的输入,对每个输入执行 Conv2D,然后将它们连接起来以再次获取 4D 数据以进行进一步处理。
任何有关实施的帮助都会有所帮助。我正在使用 Keras。
编辑:我尝试使用以下代码执行 2D 卷积
num_ch= 24
input= Input(shape=(64,64,10,num_ch))
print(input.shape)
branch_out= []
for i in range(num_ch):
out= Lambda(lambda x: x[:,:,:,:,i] )(input)
print(out.shape)
out= Conv2D(10, kernel_size=(3,3),strides= (1,1), padding='same', data_format= 'channels_last')(input)
branch_out.append(out)
我收到以下错误:
(?, 64, 64, 10, 24)
(?, 64, 64, 10)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-83-51977f4edbba> in <module>
7 out= Lambda(lambda x: x[:,:,:,:,i] )(input)
8 print(out.shape)
----> 9 out= Conv2D(10, kernel_size=(3,3),strides= (1,1), padding='same', data_format= 'channels_last')(input)
10 branch_out.append(out)
~/anaconda3/lib/python3.7/site-packages/keras/engine/base_layer.py in __call__(self, inputs, **kwargs)
412 # Raise exceptions in case the input is not compatible
413 # with the input_spec specified in the layer constructor.
--> 414 self.assert_input_compatibility(inputs)
415
416 # Collect input shapes to build layer.
~/anaconda3/lib/python3.7/site-packages/keras/engine/base_layer.py in assert_input_compatibility(self, inputs)
309 self.name + ': expected ndim=' +
310 str(spec.ndim) + ', found ndim=' +
--> 311 str(K.ndim(x)))
312 if spec.max_ndim is not None:
313 ndim = K.ndim(x)
ValueError: Input 0 is incompatible with layer conv2d_25: expected ndim=4, found ndim=5
【问题讨论】:
标签: python keras conv-neural-network