File size: 5,044 Bytes
010c443
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18ff1be
010c443
18ff1be
010c443
18ff1be
 
010c443
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18ff1be
 
010c443
 
18ff1be
 
010c443
 
 
 
18ff1be
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
010c443
 
 
 
18ff1be
010c443
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
---
license: bsd-3-clause
library_name: braindecode
pipeline_tag: feature-extraction
tags:
  - eeg
  - biosignal
  - pytorch
  - neuroscience
  - braindecode
  - convolutional
  - sleep-staging
---

# DeepSleepNet

DeepSleepNet from Supratak et al (2017) [Supratak2017].

> **Architecture-only repository.** Documents the
> `braindecode.models.DeepSleepNet` class. **No pretrained weights are
> distributed here.** Instantiate the model and train it on your own
> data.

## Quick start

```bash
pip install braindecode
```

```python
from braindecode.models import DeepSleepNet

model = DeepSleepNet(
    n_chans=2,
    sfreq=100,
    input_window_seconds=30.0,
    n_outputs=5,
)
```

The signal-shape arguments above are illustrative defaults — adjust to
match your recording.

## Documentation
- Full API reference: <https://braindecode.org/stable/generated/braindecode.models.DeepSleepNet.html>
- Interactive browser (live instantiation, parameter counts):
  <https://huggingface.co/spaces/braindecode/model-explorer>
- Source on GitHub: <https://github.com/braindecode/braindecode/blob/master/braindecode/models/deepsleepnet.py#L12>


## Architecture

![DeepSleepNet architecture](https://raw.githubusercontent.com/akaraspt/deepsleepnet/master/img/deepsleepnet.png)


## Parameters

| Parameter | Type | Description |
|---|---|---|
| `activation_large` | type[nn.Module], default=nn.ELU | Activation class for the large-filter CNN path. |
| `activation_small` | type[nn.Module], default=nn.ReLU | Activation class for the small-filter CNN path. |
| `return_feats` | bool, default=False | If True, return features before the final linear layer. |
| `drop_prob` | float, default=0.5 | Dropout probability applied throughout the network. |
| `bilstm_hidden_size` | int, default=512 | Hidden size of the BiLSTM. The residual FC output dimension is `2 * bilstm_hidden_size` to match the concatenated directions. |
| `bilstm_num_layers` | int, default=2 | Number of stacked BiLSTM layers. |
| `small_n_filters_1` | int, default=64 | First-conv output channels for the small-filter path. |
| `small_n_filters_2` | int, default=128 | Deep-conv (conv2--conv4) output channels for the small-filter path. |
| `small_first_kernel_size` | int, default=50 | First-conv kernel size for the small path (paper: Fs/2). |
| `small_first_stride` | int, default=6 | First-conv stride for the small path (paper: Fs/16). |
| `small_first_padding` | int, default=22 | First-conv padding for the small path. |
| `small_pool1_kernel_size` | int, default=8 | First max-pool kernel for the small path. |
| `small_pool1_stride` | int, default=8 | First max-pool stride for the small path. |
| `small_pool1_padding` | int, default=2 | First max-pool padding for the small path. |
| `small_deep_kernel_size` | int, default=8 | Deep-conv kernel size for the small path. |
| `small_pool2_kernel_size` | int, default=4 | Second max-pool kernel for the small path. |
| `small_pool2_stride` | int, default=4 | Second max-pool stride for the small path. |
| `small_pool2_padding` | int, default=1 | Second max-pool padding for the small path. |
| `large_n_filters_1` | int, default=64 | First-conv output channels for the large-filter path. |
| `large_n_filters_2` | int, default=128 | Deep-conv (conv2--conv4) output channels for the large-filter path. |
| `large_first_kernel_size` | int, default=400 | First-conv kernel size for the large path (paper: 4*Fs). |
| `large_first_stride` | int, default=50 | First-conv stride for the large path (paper: Fs/2). |
| `large_first_padding` | int, default=175 | First-conv padding for the large path. |
| `large_pool1_kernel_size` | int, default=4 | First max-pool kernel for the large path. |
| `large_pool1_stride` | int, default=4 | First max-pool stride for the large path. |
| `large_pool1_padding` | int, default=0 | First max-pool padding for the large path. |
| `large_deep_kernel_size` | int, default=6 | Deep-conv kernel size for the large path. |
| `large_pool2_kernel_size` | int, default=2 | Second max-pool kernel for the large path. |
| `large_pool2_stride` | int, default=2 | Second max-pool stride for the large path. |
| `large_pool2_padding` | int, default=1 | Second max-pool padding for the large path. |


## References

1. Supratak, A., Dong, H., Wu, C., & Guo, Y. (2017). DeepSleepNet: A model for automatic sleep stage scoring based on raw single-channel EEG. IEEE Transactions on Neural Systems and Rehabilitation Engineering, 25(11), 1998-2008.


## Citation

Cite the original architecture paper (see *References* above) and braindecode:

```bibtex
@article{aristimunha2025braindecode,
  title   = {Braindecode: a deep learning library for raw electrophysiological data},
  author  = {Aristimunha, Bruno and others},
  journal = {Zenodo},
  year    = {2025},
  doi     = {10.5281/zenodo.17699192},
}
```

## License

BSD-3-Clause for the model code (matching braindecode).
Pretraining-derived weights, if you fine-tune from a checkpoint,
inherit the licence of that checkpoint and its training corpus.