vlawhern / arl-eegmodels

This is the Army Research Laboratory (ARL) EEGModels Project: A Collection of Convolutional Neural Network (CNN) models for EEG signal classification, using Keras and Tensorflow
Other
1.14k stars 284 forks source link

Using the weights EEGNet_8_2 #17

Closed lherbeur closed 3 years ago

lherbeur commented 4 years ago

Hi, Thanks for this. I was looking to make use of the weights in EEGNet_8_2.h5 file but I'm encountering errors. Though, my data is in a different shape (16, 768), I was thinking with the necessary params defined (Chans, Samples...),I could create the model and then load the weights from the file. Error: Shapes (1, 64, 1, 16) and (8, 1, 1, 32) are incompatible I know the dimensions are different but I was thinking it could carry through somehow. How would you suggest going about this? Thanks.

vlawhern commented 4 years ago

Note that those weights were trained on the example data used in the ERP.py sample script; they shouldn't be used anywhere else other than that specific dataset. Those weights were provided purely as an example of how to load from an existing weights file and shouldn't be used for other analyses (unless if analyzing the MNE sample data is what you intend on analyzing).

If you still want to use the weights: (1) it seems you forgot to change your Keras variable "image_data_format". It needs to be "channels_first"

(2) Your data input should also be (trials, 1, channels, samples)

lherbeur commented 4 years ago

Thanks. I was thinking I could do some transfer learning with that and remove some layers but in this case, it seems it might not work. The Keras backend param is "channels_first" and the input is in the right shape. I was thinking weights from the pre-trained model could be adapted for EEG-based attention classification. Thanks.

vlawhern commented 4 years ago

Yeah I definitely wouldn't recommend using these weights for that purpose. You could probably look at any number of open-source EEG datasets as better starting points for transfer learning research, such as the motor imagery datasets described in Cho et. al. (2017), https://academic.oup.com/gigascience/article/6/7/gix034/3796323 and Kaya et. al. (2018), https://www.nature.com/articles/sdata2018211. Although they're pretty small, the Berlin BCI datasets could also be used (http://www.bbci.de/competition/iv/).

lherbeur commented 4 years ago

Wow! Cool! Thanks a lot. This is really informative and helpful.