Help with setting up a Convolutional Neural Network

Hello,

I’m trying to finish a thesis in biology. The goal is learning to distinguish between different types of thinking process recorded via EEG through a Convolutional Neural Network. I’m using a model provided by geopopos from github: GitHub - geopopos/EEG_convolutional_neural_net: A convolutional neural network developed in python using the Keras machine learning framework used to categorize brain signal based on what a user was looking at when the EEG data was collected.

The problem is I’m not very well versed in neural networks and while I understand their principles and how to set up some simple NNs, I’m not skilled enough to properly get a beast like a CNN to work. I’ve been trying to make it work on my EEG to no avail and tried to make it work on some other EEG provided by Machine Learning Repository (https://archive.ics.uci.edu/ml/datasets/EEG+Steady-State+Visual+Evoked+Potential+Signals#), again, to no avail. After the last fiasco I figured it might not be a fault with my EEG recordings but rather with how I worked the model provided by geopopos that prevents me from getting any results.
Namely, I lack understanding on how configure a shapes of the data used within the model, it’s pretty manipulated throughout and I lack understanding in how to efficiently set it up:

model.add(Convolution2D(40, (1,5), activation=“relu”, input_shape=(1,124,32), data_format=“channels_first”))
model.add(Permute((3,2,1)))
model.add(Reshape((1,28,124,40)))
model.add(Convolution3D(40, (1,124,40), activation=“relu”, data_format=“channels_first”))
model.add(Lambda(lambda x: x ** 2))
model.add(Reshape((40,28,1)))
model.add(AveragePooling2D((1, 5), (1, 1)))
model.add(Activation(“relu”))
model.add(Lambda(logIt))
model.add(Flatten())
model.add(Dense(6, activation=“softmax”))
model.summary()

The shape of my data is different and I don’t really understand how to efficiently work all the permutes, reshapes and how to set up shapes for convolutional layers, as well as how to better set up my data.

While I am interested in machine learning and has learned a lot about it, my field is biology and I lack expertise for that right now, and I need more skilled people to help me finish my thesis. I need your help a lot.

Thank you.

Hi @fivepointsgang,

Sorry for the delayed response. Hope you had a solution by this time. Upon observing the code you are trying to generate a neural network model to categorize the thinking process using EEG data. If you are working with time series data, might the data format be channels, timestamps. As Conv2D is the first layer, the input data shape must be compatible batch size, height, width, channels to it and for Conv3D, the data from the previous layer need to be reshaped to batch size, depth, height, width. channels. Similar use case tutorial is attached here for reference. Please configure the network layers according to your case.

Thank You