Shortcuts

DeepSleepNet

class torcheeg.models.DeepSleepNet(num_classes: int = 2, chunk_size: int = 3000, num_electrodes: int = 1, dropout: float = 0.5, n_filters_1: int = 64, filter_size_1: int = 50, filter_stride_1: int = 6, n_filters_2: int = 64, filter_size_2: int = 400, filter_stride_2: int = 50, pool_size_11: int = 8, pool_stride_11: int = 8, pool_size_21: int = 4, pool_stride_21: int = 4, n_filters_1x3: int = 128, filter_size_1x3: int = 8, n_filters_2x3: int = 128, filter_size_2x3: int = 6, pool_size_12: int = 4, pool_stride_12: int = 4, pool_size_22: int = 2, pool_stride_22: int = 2)[source][source]

A deep learning model for automatic sleep stage scoring based on raw single-channel EEG. For more details, please refer to the following information.

Below is a quick start example:

from torcheeg.models import DeepSleepNet

model = DeepSleepNet(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 small-filter convolution path. (default: 64)

  • filter_size_1 (int) – Filter size for the first convolution in small-filter path. (default: 50)

  • filter_stride_1 (int) – Stride for the first convolution in small-filter path. (default: 6)

  • n_filters_2 (int) – Number of filters in the first large-filter convolution path. (default: 64)

  • filter_size_2 (int) – Filter size for the first convolution in large-filter path. (default: 400)

  • filter_stride_2 (int) – Stride for the first convolution in large-filter path. (default: 50)

  • pool_size_11 (int) – Pooling size after first small-filter convolution. (default: 8)

  • pool_stride_11 (int) – Pooling stride after first small-filter convolution. (default: 8)

  • pool_size_21 (int) – Pooling size after first large-filter convolution. (default: 4)

  • pool_stride_21 (int) – Pooling stride after first large-filter convolution. (default: 4)

  • n_filters_1x3 (int) – Number of filters in small-filter path’s residual blocks. (default: 128)

  • filter_size_1x3 (int) – Filter size in small-filter path’s residual blocks. (default: 8)

  • n_filters_2x3 (int) – Number of filters in large-filter path’s residual blocks. (default: 128)

  • filter_size_2x3 (int) – Filter size in large-filter path’s residual blocks. (default: 6)

  • pool_size_12 (int) – Final pooling size in small-filter path. (default: 4)

  • pool_stride_12 (int) – Final pooling stride in small-filter path. (default: 4)

  • pool_size_22 (int) – Final pooling size in large-filter path. (default: 2)

  • pool_stride_22 (int) – Final pooling stride in large-filter path. (default: 2)

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 Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources