EEGInception
- class selfeeg.models.zoo.EEGInception(nb_classes: int, Chans: int, Samples: int, F1: int = 8, D: int = 2, kernel_size: int = 64, pool: int = 4, dropRate: float = 0.5, ELUalpha: float = 1.0, bias: bool = True, batch_momentum: float = 0.1, max_depth_norm: float = 1.0, return_logits: bool = True, seed: int = None)[source]
Pytorch Implementation of the EEGInception model. Original paper can be found here [eeginc] . A Keras implementation can be found here [eegincgit] .
The expected input is a 3D tensor with size (Batch x Channels x Samples).
- Parameters:
nb_classes (int) – The number of classes. If less than 2, a binary classification problem is considered (output dimensions will be [batch, 1] in this case).
Chans (int) – The number of EEG channels.
Samples (int) – The sample length. It will be used to calculate the embedding size (for head initialization).
F1 (int, optional) –
The number of filters in the first temporal convolutional layer. Other output filters will be calculated according to the paper specification.
Default = 8
D (int, optional) –
The depth of the depthwise convolutional layer.
Default = 2
kernel_size (int, optional) –
The length of the temporal convolutional layer.
Default = 64
pool (int, optional) –
The temporal pooling kernel size.
Default = 4
dropRate (float, optional) –
The dropout percentage in range [0,1].
Default = 0.5
ELUalpha (float, optional) –
The alpha value of the ELU activation function.
Default = 1
bias (bool, optional) –
If True, add a learnable bias to the output.
Default = True
batch_momentum (float, optional) –
The batch normalization momentum.
Default = 0.9
max_depth_norm (float, optional) –
The maximum norm each filter can have in the depthwise block. If None no constraint will be included.
Default = 1.
return_logits (bool, optional) –
Whether to return the output as logit or probability. It is suggested to not use False as the pytorch crossentropy applies the softmax internally.
Default = True
seed (int, optional) –
A custom seed for model initialization. It must be a nonnegative number. If None is passed, no custom seed will be set
Default = None
References
[eeginc]Zhang, Ce, Young-Keun Kim, and Azim Eskandarian. “EEG-inception: an accurate and robust end-to-end neural network for EEG-based motor imagery classification.” Journal of Neural Engineering 18.4 (2021): 046014. https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=9311146
Example
>>> import selfeeg.models >>> import torch >>> x = torch.randn(4,8,64) >>> mdl = models.EEGInception(4,8,64) >>> out = mdl(x) >>> print(out.shape) # shoud return torch.Size([4, 4]) >>> print(torch.isnan(out).sum()) # shoud return 0