STNetEncoder
- class selfeeg.models.encoders.STNetEncoder(Samples, F: int = 256, kernlength: int = 5, dropRate: float = 0.5, bias: bool = True, seed: int = None)[source]
Pytorch implementation of the STNet Encoder.
See STNet for some references. The expected input is a 4D tensor with size (Batch x Samples x Grid_width x Grid_width), i.e. the classical 2d matrix with rows as channels and columns as samples is rearranged in a 3d tensor where the first is the Sample dimension and the last 2 dimensions are the channel dim rearrange in a 2d grid. Check the original paper for a better understanding of the input.
- Parameters:
Sample (int) – The number of EEG Samples.
F (int, optional) –
The number of output filters in the convolutional layer.
Default = 8
kernLength (int, optional) –
The length of the convolutional layer.
Default = 5
dropRate (float, optional) –
The dropout percentage in range [0,1].
Default = 0.5
bias (bool, optional) –
If True, adds a learnable bias to the convolutional layers.
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
Example
>>> import selfeeg.models >>> import torch >>> x = torch.randn(4,128,9,9) >>> mdl = models.STNetEncoder(128) >>> out = mdl(x) >>> print(out.shape) # shoud return torch.Size([4, 1296]) >>> print(torch.isnan(out).sum()) # shoud return 0