这实际上来自我之前的问题How to apply convolution on the last three dimensions of a 5D tensor using the Conv2D in Keras?
我想对N中的每个i进行二维卷积,其维度为batch_size * N * n * n * channel_size
的层。预期输出为batch_size * N * m * m * channel_size2
。每个i的权重应该不同。在回答上一个问题之后,我做了以下事情:
set=[]
for i in range(N):
conv = Conv2D(2,(4,4), strides = (4,4), activation = 'relu') \
(Lambda(lambda x : x[:,i,:,:,:])(input_layer)) # split the tensor and apply the convolution
resh = Reshape((1,4,4,2))(conv) #expand the dimension for concatenation
set.append(resh)
conv_layer = Concatenate(axis = 1)(set)
该代码似乎是正确的。但是它具有以下缺点:
任何建议将不胜感激。