Closed sagihaider closed 4 years ago
You'll need to change the Keras variable "image_data_format" to "channels_first". You can do this in one of two ways:
from tensorflow.keras import backend as K
K.set_image_data_format('channels_first')
Many thanks, working now.
Hi, I did run your EEGNet model with BCI competition IV Dataset 2A for 4-classes. In total, there were 288 trials, 22 channels, and 1750 is the trial length.
The input, I have to your model is
273 trials because rest are discarded as bad trials, 22 channels, and from each trial, I only selected the data after the cue from 0s to 3s after cue. In code sample =750. In 273 trials, I kept 200 for training and 73 for validation.
Results: I kept 100 epochs, training accuracy was 91% and validation was 73% which I think is higher than what you have said in your paper. I remember from 4 class you reported 44%. I am wondering is that on Session-1 data or you tested it in session-II data. If you want, please see my Repo Colab Notebook
So there are a couple of things to note:
The paper uses [0.5, 2.5]s post cue as the data window. This was chosen primarily to avoid the visual-evoked potential that appears due to presentation of the visual cue. I believe there is some documentation stating that for this data eye movements are more prevalent in the first 0.5s since participants visually attended to the cue. The presence of the VEP probably doesn't effect overall classification performance since every trial would have it, but I've seen [0.5, 2.5]s used in a couple other papers so I decided to use that.
I don't perform any data/trial rejection due to artifacts. I just took the data as-is and filtered it at 4-40Hz according to the pipeline described by @robintibor in (https://onlinelibrary.wiley.com/doi/full/10.1002/hbm.23730), his code-base is at (https://github.com/TNTLFreiburg/braindecode)
I down-sampled the data to 128Hz instead of the default 250Hz; I don't think this really matters much in terms of classification performance.
I did 4-fold block-wise cross-validation, fixing the test set to be the official BCI IV 2A test set. What this means is: take each subjects training data, divide it into three contiguous, non-overlapping blocks. Choose two of those blocks to be the training set, set the remaining block to be the validation set. Perform minibatch gradient descent, minimizing validation set categorical cross-entropy loss. Then evaluate model on the held-out test set. The classification performances reported in the paper are the test set classification accuracies averaged across all folds.
So your results may still be right; having a larger window at [0,3]s could potentially improve classification performance. This is something I haven't really tested.
Dear,
Many thanks for your suggestions. I used Dataset 2A and trained on session 1 data and evaluated it in Session 2 data. The transitioning phase from one session to others has a covariate shift in the data for each subject. But, your model is working very well just changing a few parameters. Thanks. Good work guys :-)
Good to hear! Let me know if any other issues arise.
Hello! I had the same problem, but when I put these lines from tensorflow.keras import backend as K K.set_image_data_format('channels_first'), I receive tensorflow.python.framework.errors_impl.InvalidArgumentError: Default AvgPoolingOp only supports NHWC on device type CPU. How could I solve this?
@mariasapantan what version of tensorflow are you using and how did you install tensorflow?
The above error comes up if you installed the CPU version of tensorflow through pip; i.e. pip install tensorflow
, see Issue #18. There are a couple of ways around this:
conda
as conda install tensorflow
. Alternatively, if you're not using the Anaconda python distribution you can install the intel-tensorflow
package through pip as pip install intel-tensorflow
which is a version of Tensorflow compiled against the Intel MKL which fixes the above issue.I'm not using Anaconda distribution and I have CPU version. I installed pip install intel-tensorflow. Now I have to uninstall tensorflow or what's next?
Yes I believe you should uninstall all previous versions of tensorflow and install intel-tensorflow. Then things "should" work out of the box.
It seens like the tensorflow is uninstalled when I putpip list
, but when I look at project interpreter in PyCharm, tensorflow is there. Intel-tensorflow does not have keras when I try to import it
So I ran a quick test using the intel-tensorflow
package and everything works for me:
from tensorflow.keras import backend as K
K.set_image_data_format('channels_first')
you may have to restart your interpreter after you make package changes? I don't use pycharm so I'm not sure how to troubleshoot there..
Note I'm using Python 3.7, but I doubt this matters much whether you're on Python 3.7/3.8/etc. You should double-check if all tensorflow packages are uninstalled, then try to install intel-tensorflow
again.
Otherwise I'm not sure how to help from here..
I have AMD processor. I tried a lot of things, but it does not work for me. Could you help me via TeamViewer?
I am using EEGNet model for classifying 4-class BCI competition IV Dataset 2a for Motor Imagery detection i.e. detecting (SMR) I read the data for one subject using the MAT file I have. After reading the training data, the x
The output is :
where 272 are trials, 22 channels, 1500 samples from each trial
I partitioned and cropped the data. The cropping I did because the data in the region 500:1000 (i.e. from the start of the cue to the 2 sec after cue) is much related for ERD/ERS.
Output:
Following parameter, I used and reshaped the data
Output:
Now, while creating the model
Now the error, I am getting is given as follows:
ValueError: Negative dimension size caused by subtracting 22 from 8 for 'depthwise_conv2d/depthwise' (op: 'DepthwiseConv2dNative') with input shapes: [?,8,22,500], [22,1,500,2].
I am wondering what mistake I am making? any clue, please Many thanks