CVxTz / EEG_classification

EEG Sleep stage classification using CNN with Keras
Apache License 2.0
149 stars 39 forks source link

Alignment of base model output and get_model_input #4

Closed zizi96 closed 4 years ago

zizi96 commented 4 years ago

Hello I'm trying to alter your code for a project. From what I see the get_model_cnn is expecting input shape of (None, 3000, 1) (see in seq_input) , but you are passing input as (None, 64) (which is output of get_base_model). This is causing an Error when checking target: expected 3 dimensions, but got array with shape (32, 6) in the out layer of get_model_cnn.

Could let me if know if this is the intended output and input shapes of the base_model and get_model_cnn?

CVxTz commented 4 years ago

Hello, The input of get_base_model is (3000, 1) and its output is (64,) , this model should not be used on its own but as part of get_model_cnn. The input of get_model_cnn is (None, 3000, 1), the submodel that outputs (64, ) is only part of it.

CVxTz commented 4 years ago

Go here for an explanation : https://towardsdatascience.com/sleep-stage-classification-from-single-channel-eeg-using-convolutional-neural-networks-5c710d92d38e

zizi96 commented 4 years ago

Ok so I think the issue is with my training input shape, I'm still fairly new to ML.

Am i correct in assuming this code taken from the run-file feeds training samples (of shape 3000,1) into base_model 1 at a time?

train_val, test = [x for x in files if x.split("/")[-1][:5] in train_ids],\
                  [x for x in files if x.split("/")[-1][:5] in test_ids]

train, val = train_test_split(train_val, test_size=0.1, random_state=1337)

train_dict = {k: np.load(k) for k in train}
test_dict = {k: np.load(k) for k in test}
val_dict = {k: np.load(k) for k in val}
CVxTz commented 4 years ago

No its wrong. You need to checkout the function "gen" in https://github.com/CVxTz/EEG_classification/blob/master/code/utils.py

zizi96 commented 4 years ago

I have an idea but its only a guess. I tried generating the data myself to check myself but I don't use Linux. Its very difficult to visualise what gen is doing without knowing exactly what the data into it looks like hence why I would greatly appreciate knowing the shape of what gen outputs. From there I could learn whats going on with pre-processing via reverse engineering. Thanks for your time.

CVxTz commented 4 years ago

gen outputs X, Y. X shape is (batch_size, 100, 3000, 1) Y shape is (batch_size, 100, 1) You can double check by calling : X, Y = next(gen(train)) print(X.shape) print(Y.shape)