I have N vectors of a temporal (t) data with t points and this data have 2 features (Oxy hemoglobin - HbO and Deoxy-hemoglobin - HbR). So it is a temporal series of the concentration of this 2 types of hemoglobin along the head of a person. Each vector is one data from one position of the head (in my code i call it channel->pair of a source-detector). So I have about 1000 samples of these.
E organized my data in a 3d tensor: height -> time, width -> vector in the head, depth -> 2 feature`s Hemoglobin
In this case I think that Hemoglobins type is my "channel" (like RGB to images - like this Link of CNN-dimension)
For example, I have a data of: 89 times points x 5 vectors x 2 features hemoglobin. One sample look like that image:
So, i want to do a Conv1D to classificate this samples in two types. My model is very simple:
def Model_CNN(n_times, n_ch):
model = Sequential()
model.add(Conv1D(filters=20, kernel_size= (3,n_ch,2), name = 'Conv1D_01',
strides=1,data_format='channels_last',
activation='relu', input_shape=(n_times,n_channels,2), padding='same'))
model.add(MaxPooling1D(pool_size= 3, strides=3,padding='same', name = 'MaxPool_01'))
model.add(Conv1D(filters=50, kernel_size= 3, name = 'Conv1D_02',
strides=1,data_format='channels_last',
activation='relu', padding='same'))
model.add(MaxPooling1D(pool_size= 3, strides=3,padding='same', name = 'MaxPool_02'))
model.add(Flatten())
model.add(Dense(30, activation='relu'))
model.add(Dense(10, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(2, activation='softmax'))
model.summary()
return model
So I dont know how to specifies my kernel_size and my input_shape. I think my kernel must be 3 x Nvectors x 2HbO . In the image example it will be something like 3 times point x 5 ch x 2 Hb`s . And my convolution will move in only one direction of time (in this case, top to bottom).
If I put kernel_size = (3,n_channels,2) i get the error:
ValueError: The `kernel_size` argument must be a tuple of 1 integers. Received: (3, 64, 2)
If I put kernel_size = 3 i get the error:
ValueError: Input 0 of layer MaxPool_01 is incompatible with the layer: expected ndim=3, found ndim=4. Full shape received: (None, 89, 64, 20)
How can I do this works ? I would like to choose kernel with 3 points of times.