TinySleepNetEncoder
- class selfeeg.models.encoders.TinySleepNetEncoder(Chans: int, Fs: int, F: int = 128, kernlength: int = 8, pool: int = 8, dropRate: float = 0.5, batch_momentum: float = 0.1, hidden_lstm: int = 128, seed: int = None)[source]
Pytorch Implementation of the TinySleepNet Encoder.
TinySleepNet is a minimal but better performing architecture derived from DeepSleepNet (proposed by the same authors). See TinySleepNet 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.
Fs (float) – The EEG sampling frequency in Hz.
F1 (int, optional) –
The number of output filters in the representation learning part.
Default = 128
kernlength (int, optional) –
The length of the temporal convolutional layer.
Default = 8
pool (int, optional) –
The temporal pooling kernel size.
Default = 8
dropRate (float, optional) –
The dropout percentage in range [0,1].
Default = 0.5
hidden_lstm (int, optional) –
Hidden size of the lstm block.
Default = 128
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,8,1024) >>> mdl = models.TinySleepNetEncoder(8,32) >>> out = mdl(x) >>> print(out.shape) # shoud return torch.Size([4, 128]) >>> print(torch.isnan(out).sum()) # shoud return 0