TinySleepNet¶
- class torcheeg.models.TinySleepNet(num_classes: int = 2, chunk_size: int = 3000, num_electrodes: int = 1, dropout: float = 0.5, n_filters_1: int = 128, filter_size_1: int = 50, filter_stride_1: int = 6, pool_size_1: int = 8, pool_stride_1: int = 8, n_filters_1x3: int = 128, filter_size_1x3: int = 8, pool_size_2: int = 4, pool_stride_2: int = 4)[source][source]¶
An efficient deep learning model for automatic sleep stage scoring based on raw single-channel EEG. For more details, please refer to the following information.
Paper: A. Supratak and Y. Guo, “TinySleepNet: An Efficient Deep Learning Model for Sleep Stage Scoring based on Raw Single-Channel EEG,” Annu Int Conf IEEE Eng Med Biol Soc, vol. 2020, pp. 641-644, Jul 2020.
Related Project: https://github.com/akaraspt/tinysleepnet
Below is a quick start example:
from torcheeg.models import TinySleepNet model = TinySleepNet(num_classes=5, chunk_size=3000, num_electrodes=1) # batch_size, 1, chunk_size, num_electrodes x = torch.randn(32, 1, 3000, 1) model(x)
- Parameters:
num_classes (int) – The number of sleep stages to classify. (default:
2)chunk_size (int) – Number of data points in each EEG segment. (default:
3000)num_electrodes (int) – The number of EEG channels. (default:
1)dropout (float) – Dropout rate for regularization. (default:
0.5)n_filters_1 (int) – Number of filters in the first convolution layer. (default:
128)filter_size_1 (int) – Filter size for the first convolution layer. (default:
50)filter_stride_1 (int) – Stride for the first convolution layer. (default:
6)pool_size_1 (int) – Pooling size after first convolution layer. (default:
8)pool_stride_1 (int) – Pooling stride after first convolution layer. (default:
8)n_filters_1x3 (int) – Number of filters in residual blocks. (default:
128)filter_size_1x3 (int) – Filter size in residual blocks. (default:
8)pool_size_2 (int) – Final pooling size. (default:
4)pool_stride_2 (int) – Final pooling stride. (default:
4)
- forward(x)[source][source]¶
Defines the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.