ShallowNetEncoder
- class selfeeg.models.encoders.ShallowNetEncoder(Chans, F: int = 40, K1: int = 25, Pool: int = 75, p: float = 0.2, seed: int = None)[source]
Pytorch implementation of the ShallowNet Encoder.
See ShallowNet for some references. The expected input is a 3D tensor with size (Batch x Channels x Samples).
- Parameters:
Chans (int) – The number of EEG channels.
F (int, optional) –
The number of output filters in the temporal convolution layer.
Default = 40
K1 (int, optional) –
The length of the temporal convolutional layer.
Default = 25
Pool (int, optional) –
The temporal pooling kernel size.
Default = 75
p (float, optional) –
Dropout probability. Must be in [0,1)
Default= 0.2
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
Note
In this implementation, the number of channels is an argument. However, in the original paper authors preprocess EEG data by selecting a subset of only 21 channels. Since the net is very minimalistic, please follow the authors’ notes.
Example
>>> import selfeeg.models >>> import torch >>> x = torch.randn(4,8,512) >>> mdl = models.ShallowNetEncoder(8) >>> out = mdl(x) >>> print(out.shape) # shoud return torch.Size([4, 224]) >>> print(torch.isnan(out).sum()) # shoud return 0