0
votes

I am implementing a 3D convolution neural network and I have two questions.

Question 1

Each input is a 3D matrix of size (201,10,4). I want my filters to move across the second and third dimension in a sense that they are fully connected. Third dimension is the feature dimension. So I don't want to look in local neighbourhoods of second and third dimension. So my filter size will be of size for example (3,10,4). So filter size is equal to second and third dimension but we have weight sharing in the first dimension. Following is my code for convolving:

## input layer
input_layer = Input((201, 10, 4))

## convolutional layers
conv_layer1 = Conv3D(filters=8, kernel_size=(3, 10, 4), activation='relu')(input_layer)
conv_layer2 = Conv3D(filters=16, kernel_size=(3, 10, 4), activation='relu')(conv_layer1)

So should I use stride here so that its only doing weight sharing across the first dimension. And remains sort of fully connected in the remaining second and third dimension?

Question two

For each matrix I have an output of shape (6,) and at each index I have frequencies for each feature. So I want my model to predict frequencies for each feature. I think I need to use MSE here. But how should my output layer look like. Should it be this:


model.add(Dense(1, activation='linear'))
opt = SGD(lr=0.01, momentum=0.9)
model.compile(loss='mean_squared_error', optimizer=opt)

or this:


model.add(Dense(6, activation='linear'))
opt = SGD(lr=0.01, momentum=0.9)
model.compile(loss='mean_squared_error', optimizer=opt)

Insights will be appreciated.

1

1 Answers

1
votes

As far as i Know Conv3D need 5 Dimension input, (None,D1,D2,D3,D4).

your filters will only move in D1,D2,D3 not in D4, as for D4 it will be sum of all filter. your same filter is always multiplied with all elements in D4, assuming D1,D2,D3 are same.

Answer 1: stride in your Con3D is not needed since your 2nd and 3rd Dimension is same as filter size, but don`t forget padding='same', otherwise your 2nd and 3rd dimension will be reduce by (filter-1).

which mean only 1st Con3D layer have (201,10,4) dimension, 2nd Conv3D layer will have (199, 1, 1), which is not optimal for 2nd Conv3D layer.

Answer 2: last layer should have neurons equal to number of outputs, your outputs are (6,) so dense layer should be Dense(6).

Note No need to add linear activation