I have implemented a 3D-convolution neural network. The shape of my input is (500,10,4,1). I only want to convolve in first dimension such that it is ‘fully connected’ in second and third dimension in a way. So I use kernel size of (30,10,4). So far it’s fine. But when I do max pooling it reduces the second and third dimension as well. But it’s only the first dimension I want to reduce. That is after doing the max-pooling I want the first dimension (500) to become 250 but I want my second dimension and third dimension to remain 10 and 4 respectively. How can I achieve that? My code so far is :
###Input shape i1 = Input(shape=(500,10, 4,1)) ###First block c1 = Conv3D(128, kernel_size=(50,10,4),activation='relu',padding='same')(i1) c1 = MaxPooling3D(2)(c1) c1 = Dropout(0.1)(c1) ###Second block #c1 = Conv3D(128, kernel_size=(50,10,4),activation='relu',padding='same')(c1) #c1 = MaxPooling3D(2)(c1) #c1 = Dropout(0.1)(c1) c = Flatten()(c1) #c2 = Dropout(0.1)(c2) ###FC Layers x = Dense(128, activation='relu')(c) ##Output output = Dense(4,activation = 'linear')(x)
ERROR When I do
c1 = MaxPooling3D(2,1,1)(c1)
I get the following error:
Insights will be appreciated.
Advertisement
Answer
try this :
c1=MaxPool3D(pool_size=(2,1,1))(c1)