StagerNet
- class selfeeg.models.zoo.StagerNet(nb_classes: int, Chans: int, Samples: int, dropRate: float = 0.5, kernLength: int = 64, F: int = 8, Pool: int = 16, return_logits: bool = True, seed: int = None)[source]
Pytorch implementation of the StagerNet model.
Original paper can be found here [stager] . 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).
dropRate (float, optional) –
The dropout percentage in range [0,1].
Default = 0.5
kernLength (int, optional) –
The length of the temporal convolutional layer.
Default = 64
F (int, optional) –
The number of output filters in the temporal convolution layer.
Default = 8
pool (int, optional) –
The temporal pooling kernel size.
Default = 16
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
[stager]Chambon et al., A deep learning architecture for temporal sleep stage classification using multivariate and multimodal time series, arXiv:1707.03321
Example
>>> import selfeeg.models >>> import torch >>> x = torch.randn(4,8,512) >>> mdl = models.StagerNet(4,8,512) >>> out = mdl(x) >>> print(out.shape) # shoud return torch.Size([4, 4]) >>> print(torch.isnan(out).sum()) # shoud return 0