I am trying to learn using deep learning in python to analyse EEG data. Unfortunately, I am also new to python, so have tried to find the simplest tools available. This has lead me to Keras.
More precisely, I am trying to implement the following pipe line:
So far, I seem to be stuck around "S1" or "C2". The idea so far is:
input sections of EEG data (1 x 6000 is what I will use for now)
run that through 20 1D filters (1x200)
However, the below code gives me the following error:
model = Sequential()
model.add(Conv1D(input_shape=(1,6000), kernel_size=200,strides=1,
activation='sigmoid',filters=20))
model.add(MaxPooling1D(pool_size=20, strides=10,padding='same'))
model.add(Conv2D(filters=400,kernel_size=(20,30),strides=(1,1),activation='sigmoid'))
Output:
ValueError: Input 0 is incompatible with layer conv2d_4: expected ndim=4, found ndim=3
I am sure this is trivial mistake, but going through the keras documentation has not made me any wiser.
I realize the above skips the "stacking" procedure, but the closest thing I could find to that was Concatenate, and that just complains that I have not given it any inputs.
I am using theano 0.9.0.dev and keras 2.0.2
You need to reshape your data before going from 1D to 2D. There is dedicated layer in Keras. I guess, your model may start like this:
model = Sequential()
model.add(Conv1D(input_shape=(6000,1),kernel_size=200,strides=1,
activation='sigmoid',filters=20))
model.add(MaxPooling1D(pool_size=20, strides=10,padding='same'))
model.add(Reshape((-1, 581, 20)))
model.add(Conv2D(filters=400,kernel_size=(20,30),strides=(1,1),
activation='sigmoid'))
I've also replaced input_shape
to default dimension ordering.