[Python] Asking advice on EEG classification using Keras

Discussão em 'Python' iniciado por Stack, Fevereiro 28, 2025.

  1. Stack

    Stack Membro Participativo

    I have a dataset on EEG, with this shape:

    (11,1158, 200)


    Where

    11 is the number of EEG channel
    1158 is the number of each task
    200 is the time interval of each task


    for example, if you plot a task, you'll get (Note that the data is normalized):

    [​IMG]

    This task represents a task with a class. (for example seeing a picture from class 2, and total number of classes in my dataset is 5).

    Now I converted my array to this shape:

    (1158, 200, 11)


    So that the model could differentiate each task. this is the model that I used:

    opt = keras.optimizers.Adam(learning_rate=1e-4)

    model = Sequential()
    model.add(Conv1D(filters=128, kernel_size=64, activation='relu', input_shape=(200, 11)))
    model.add(Conv1D(filters=64, kernel_size=8, activation='relu'))
    model.add(Dropout(0.5))
    model.add(MaxPooling1D(pool_size=2))
    model.add(Flatten())
    model.add(Dense(100, activation='relu'))
    model.add(Dense(5, activation='softmax'))
    model.compile(loss='categorical_crossentropy', optimizer=opt, metrics=['accuracy'])
    model.fit(x_train, y_train, validation_data=(x_valid,y_valid), epochs=50, batch_size=16)


    I tried many different hyper-parameters, but all my results are somewhat like this:

    Epoch 50/50
    58/58 [==============================] - 0s 5ms/step - loss: 0.1281 - accuracy: 0.9946 - val_loss: 2.7850 - val_accuracy: 0.1897


    The training accuracy is high, but validation accuracy is between 20% to 25% (100/5 = 20 where 5 is the number of classes); Which basically means the model predicts something random. Is my approach wrong? If so, how should I solve this problem?

    Continue reading...

Compartilhe esta Página