Other
PyTorch
PEFT
sleep-staging
polysomnography
eeg
eog
emg
biosignal
biosignals
signal-processing
time-series
healthcare
medical
edge-ai
tinyml
on-device
gru
cnn
depthwise-separable-convolution
gabor-filter
sleep-edf
physionet
lightweight
low-parameter
lora
parameter-efficient-fine-tuning
adapter
fine-tuning
sleep
classification
5-class
aasm
epoch-classification
wearable
iot
microcontroller
arm
cortex-m
Eval Results (legacy)
Instructions to use shamique/Light-Weight-Neuromorphic-Sleep-Stage-Model with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- PEFT
How to use shamique/Light-Weight-Neuromorphic-Sleep-Stage-Model with PEFT:
Task type is invalid.
- Notebooks
- Google Colab
- Kaggle
Update model card with 100-subject benchmark results (3 seeds × 10 folds)
Browse files
README.md
CHANGED
|
@@ -52,35 +52,27 @@ model-index:
|
|
| 52 |
name: Sleep Stage Classification
|
| 53 |
dataset:
|
| 54 |
type: sleep-edf-expanded
|
| 55 |
-
name: Sleep-EDF Expanded (
|
| 56 |
config: default
|
| 57 |
split: test
|
| 58 |
revision: main
|
| 59 |
metrics:
|
| 60 |
- type: accuracy
|
| 61 |
-
value: 0.
|
| 62 |
name: Accuracy
|
| 63 |
verified: false
|
| 64 |
- type: cohen_kappa
|
| 65 |
-
value: 0.
|
| 66 |
name: Cohen's Kappa
|
| 67 |
verified: false
|
| 68 |
- type: f1
|
| 69 |
-
value: 0.
|
| 70 |
name: Macro F1
|
| 71 |
verified: false
|
| 72 |
- type: f1
|
| 73 |
-
value: 0.
|
| 74 |
name: Weighted F1
|
| 75 |
verified: false
|
| 76 |
-
- type: f1
|
| 77 |
-
value: 0.455
|
| 78 |
-
name: N1 F1
|
| 79 |
-
verified: false
|
| 80 |
-
- type: f1
|
| 81 |
-
value: 0.803
|
| 82 |
-
name: REM F1
|
| 83 |
-
verified: false
|
| 84 |
widget:
|
| 85 |
- src: https://huggingface.co/spaces/shamique/neurosleep-demo
|
| 86 |
title: NeuroSleep Live Demo
|
|
@@ -90,9 +82,9 @@ widget:
|
|
| 90 |
|
| 91 |
# NeuroSleep — Light-Weight Sleep Stage Model
|
| 92 |
|
| 93 |
-
**99,477 parameters,
|
| 94 |
|
| 95 |
-
> **Quick links:** [GitHub](https://github.com/shamiquekhan/neuromorphic-sleep-staging-pipeline) · [Live Demo](https://huggingface.co/spaces/
|
| 96 |
|
| 97 |
A compact PyTorch model for five-stage sleep-stage classification from polysomnography signals. Processes 300 seconds of context (10 × 30-second epochs) and classifies each epoch into Wake, N1, N2, N3, or REM. Designed for edge deployment on resource-constrained devices.
|
| 98 |
|
|
@@ -177,29 +169,26 @@ Wake / N1 / N2 / N3 / REM
|
|
| 177 |
| 3 | N3 | Deep sleep |
|
| 178 |
| 4 | REM | Rapid eye movement sleep |
|
| 179 |
|
| 180 |
-
## Evaluation (
|
| 181 |
-
|
| 182 |
-
> **Note:** Evaluation uses 4-fold subject-level cross-validation with 4 held-out test subjects (SC4001, SC4002, SC4011, SC4012). The other 11 subjects appear only in training.
|
| 183 |
|
| 184 |
| Metric | Value |
|
| 185 |
|--------|-------|
|
| 186 |
-
| Accuracy |
|
| 187 |
-
| Cohen's Kappa | 0.
|
| 188 |
-
| Macro F1 | 0.
|
| 189 |
-
| Weighted F1 |
|
| 190 |
-
| Geometric Mean Recall | 0.816 ± 0.043 |
|
| 191 |
|
| 192 |
-
### Per-Class Performance
|
| 193 |
|
| 194 |
-
| Stage | F1 | Precision | Recall |
|
| 195 |
-
|-------|-----|-----------|--------|
|
| 196 |
-
| Wake | 0.
|
| 197 |
-
| N1 | **0.
|
| 198 |
-
| N2 | 0.
|
| 199 |
-
| N3 | 0.
|
| 200 |
-
| REM | 0.
|
| 201 |
|
| 202 |
-
> **Honest assessment:** Overall accuracy (
|
| 203 |
|
| 204 |
## Preprocessing
|
| 205 |
|
|
@@ -214,13 +203,14 @@ See the [source repo](https://github.com/shamiquekhan/neuromorphic-sleep-staging
|
|
| 214 |
|
| 215 |
## Training Details
|
| 216 |
|
| 217 |
-
- **Dataset:** Sleep-EDF Expanded (
|
| 218 |
-
- **Optimizer:** AdamW (lr=3e-4, weight_decay=1e-
|
| 219 |
-
- **Epochs:**
|
| 220 |
- **Class weights:** N1=2x, REM=2x
|
| 221 |
- **Supervision:** All-position (every epoch in 10-epoch window)
|
| 222 |
- **Gradient clipping:** max_norm=1.0
|
| 223 |
-
- **
|
|
|
|
| 224 |
|
| 225 |
## LoRA Adaptation (Parameter-Efficient Fine-Tuning)
|
| 226 |
|
|
@@ -230,41 +220,39 @@ The model supports **LoRA (Low-Rank Adaptation)** for efficient fine-tuning on n
|
|
| 230 |
|
| 231 |
| Property | Value |
|
| 232 |
|----------|-------|
|
| 233 |
-
| Target modules | `
|
| 234 |
| Rank | 8 |
|
| 235 |
| Alpha | 16 |
|
| 236 |
| Scaling | 2.0 |
|
| 237 |
-
| Trainable params |
|
| 238 |
|
| 239 |
### Apply LoRA
|
| 240 |
|
| 241 |
```python
|
| 242 |
-
from
|
| 243 |
-
|
| 244 |
-
lora_config =
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
target_modules=["head"],
|
| 248 |
-
|
| 249 |
-
bias="none",
|
| 250 |
)
|
| 251 |
|
| 252 |
model = ImprovedStudent()
|
| 253 |
model.load_state_dict(load_file(ckpt_path, device="cpu"))
|
| 254 |
-
model =
|
| 255 |
-
|
| 256 |
-
# trainable params: 552 || all params: 99,477 || trainable%: 0.55%
|
| 257 |
```
|
| 258 |
|
| 259 |
-
### LoRA vs Full Fine-Tuning
|
| 260 |
|
| 261 |
| Method | Trainable Params | Accuracy | Macro F1 |
|
| 262 |
|--------|-----------------|----------|----------|
|
| 263 |
-
| Frozen Base | 0 |
|
| 264 |
-
| LoRA
|
| 265 |
-
| Full Fine-Tuning | 99,477 |
|
| 266 |
|
| 267 |
-
LoRA
|
| 268 |
|
| 269 |
## Intended Use
|
| 270 |
|
|
@@ -276,10 +264,10 @@ LoRA achieves **94% of full fine-tuning accuracy** with **0.55% of the parameter
|
|
| 276 |
## Limitations
|
| 277 |
|
| 278 |
- **Not clinically validated** — do not use for diagnosis or clinical decision-making
|
| 279 |
-
- N1 classification is challenging (F1=0.
|
| 280 |
-
- Trained on Sleep-EDF Expanded (
|
| 281 |
- Requires 4-channel PSG (Fpz-Cz, Pz-Oz, EOG, EMG) — single-channel EEG not supported
|
| 282 |
-
- Class distribution is Wake-dominant (68
|
| 283 |
|
| 284 |
## Resources
|
| 285 |
|
|
|
|
| 52 |
name: Sleep Stage Classification
|
| 53 |
dataset:
|
| 54 |
type: sleep-edf-expanded
|
| 55 |
+
name: Sleep-EDF Expanded (92 subjects, PhysioNet)
|
| 56 |
config: default
|
| 57 |
split: test
|
| 58 |
revision: main
|
| 59 |
metrics:
|
| 60 |
- type: accuracy
|
| 61 |
+
value: 0.877
|
| 62 |
name: Accuracy
|
| 63 |
verified: false
|
| 64 |
- type: cohen_kappa
|
| 65 |
+
value: 0.763
|
| 66 |
name: Cohen's Kappa
|
| 67 |
verified: false
|
| 68 |
- type: f1
|
| 69 |
+
value: 0.730
|
| 70 |
name: Macro F1
|
| 71 |
verified: false
|
| 72 |
- type: f1
|
| 73 |
+
value: 0.890
|
| 74 |
name: Weighted F1
|
| 75 |
verified: false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
widget:
|
| 77 |
- src: https://huggingface.co/spaces/shamique/neurosleep-demo
|
| 78 |
title: NeuroSleep Live Demo
|
|
|
|
| 82 |
|
| 83 |
# NeuroSleep — Light-Weight Sleep Stage Model
|
| 84 |
|
| 85 |
+
**99,477 parameters, 87.7% accuracy (κ=0.763) — small enough for edge/wearable deployment, scoring Wake/N1/N2/N3/REM from 4-channel PSG.**
|
| 86 |
|
| 87 |
+
> **Quick links:** [GitHub](https://github.com/shamiquekhan/neuromorphic-sleep-staging-pipeline) · [Live Demo](https://huggingface.co/spaces/shamiquekhan/neurosleep-demo) · [Kaggle](https://www.kaggle.com/shamiquekhan/neurosleep-final)
|
| 88 |
|
| 89 |
A compact PyTorch model for five-stage sleep-stage classification from polysomnography signals. Processes 300 seconds of context (10 × 30-second epochs) and classifies each epoch into Wake, N1, N2, N3, or REM. Designed for edge deployment on resource-constrained devices.
|
| 90 |
|
|
|
|
| 169 |
| 3 | N3 | Deep sleep |
|
| 170 |
| 4 | REM | Rapid eye movement sleep |
|
| 171 |
|
| 172 |
+
## Evaluation (92 subjects, 10-fold subject-level CV, 3 seeds)
|
|
|
|
|
|
|
| 173 |
|
| 174 |
| Metric | Value |
|
| 175 |
|--------|-------|
|
| 176 |
+
| Accuracy | 87.7% ± 2.7% |
|
| 177 |
+
| Cohen's Kappa | 0.763 ± 0.043 |
|
| 178 |
+
| Macro F1 | 0.730 ± 0.037 |
|
| 179 |
+
| Weighted F1 | 89.0% ± 2.1% |
|
|
|
|
| 180 |
|
| 181 |
+
### Per-Class Performance (Full Fine-Tuning)
|
| 182 |
|
| 183 |
+
| Stage | F1 | Precision | Recall |
|
| 184 |
+
|-------|-----|-----------|--------|
|
| 185 |
+
| Wake | 0.964 ± 0.016 | 0.995 | 0.936 |
|
| 186 |
+
| N1 | **0.445 ± 0.061** | 0.330 | 0.712 |
|
| 187 |
+
| N2 | 0.768 ± 0.041 | 0.878 | 0.687 |
|
| 188 |
+
| N3 | 0.681 ± 0.114 | 0.562 | 0.896 |
|
| 189 |
+
| REM | 0.771 ± 0.078 | 0.772 | 0.785 |
|
| 190 |
|
| 191 |
+
> **Honest assessment:** Overall accuracy (87.7%) is strong with balanced performance across all five stages. N1 is the most challenging stage (F1=0.445) due to its transitional nature and low prevalence (~4.6% of epochs).
|
| 192 |
|
| 193 |
## Preprocessing
|
| 194 |
|
|
|
|
| 203 |
|
| 204 |
## Training Details
|
| 205 |
|
| 206 |
+
- **Dataset:** Sleep-EDF Expanded (92 subjects, PhysioNet)
|
| 207 |
+
- **Optimizer:** AdamW (lr=3e-4, weight_decay=1e-4)
|
| 208 |
+
- **Epochs:** 20 (early stopping patience=5)
|
| 209 |
- **Class weights:** N1=2x, REM=2x
|
| 210 |
- **Supervision:** All-position (every epoch in 10-epoch window)
|
| 211 |
- **Gradient clipping:** max_norm=1.0
|
| 212 |
+
- **Mixed precision:** True (CUDA)
|
| 213 |
+
- **Seeds:** 42, 43, 44 (30 folds per method)
|
| 214 |
|
| 215 |
## LoRA Adaptation (Parameter-Efficient Fine-Tuning)
|
| 216 |
|
|
|
|
| 220 |
|
| 221 |
| Property | Value |
|
| 222 |
|----------|-------|
|
| 223 |
+
| Target modules | `enc.0.pw`, `enc.1.pw`, `head` |
|
| 224 |
| Rank | 8 |
|
| 225 |
| Alpha | 16 |
|
| 226 |
| Scaling | 2.0 |
|
| 227 |
+
| Trainable params | 1,448 (1.43% of total) |
|
| 228 |
|
| 229 |
### Apply LoRA
|
| 230 |
|
| 231 |
```python
|
| 232 |
+
from sleep_staging.adaptation.lora import LoRAConfig, apply_lora
|
| 233 |
+
|
| 234 |
+
lora_config = LoRAConfig(
|
| 235 |
+
rank=8,
|
| 236 |
+
alpha=16,
|
| 237 |
+
target_modules=["enc.0.pw", "enc.1.pw", "head"],
|
| 238 |
+
dropout=0.05,
|
|
|
|
| 239 |
)
|
| 240 |
|
| 241 |
model = ImprovedStudent()
|
| 242 |
model.load_state_dict(load_file(ckpt_path, device="cpu"))
|
| 243 |
+
model = apply_lora(model, lora_config)
|
| 244 |
+
# trainable params: 1,448 || all params: 99,477 || trainable%: 1.43%
|
|
|
|
| 245 |
```
|
| 246 |
|
| 247 |
+
### LoRA vs Full Fine-Tuning (100-Subject Benchmark)
|
| 248 |
|
| 249 |
| Method | Trainable Params | Accuracy | Macro F1 |
|
| 250 |
|--------|-----------------|----------|----------|
|
| 251 |
+
| Frozen Base | 0 | 87.1% | 0.673 |
|
| 252 |
+
| LoRA CNN+Head | 1,448 | 83.6% | 0.674 |
|
| 253 |
+
| **Full Fine-Tuning** | **99,477** | **87.7%** | **0.730** |
|
| 254 |
|
| 255 |
+
LoRA CNN+Head uses **68.7× fewer trainable parameters** while retaining **95.4% of full FT accuracy**.
|
| 256 |
|
| 257 |
## Intended Use
|
| 258 |
|
|
|
|
| 264 |
## Limitations
|
| 265 |
|
| 266 |
- **Not clinically validated** — do not use for diagnosis or clinical decision-making
|
| 267 |
+
- N1 classification is challenging (F1=0.445) due to brief, transitional light sleep
|
| 268 |
+
- Trained on Sleep-EDF Expanded (92 subjects); generalizability should be validated
|
| 269 |
- Requires 4-channel PSG (Fpz-Cz, Pz-Oz, EOG, EMG) — single-channel EEG not supported
|
| 270 |
+
- Class distribution is Wake-dominant (~68%) from untrimmed recordings
|
| 271 |
|
| 272 |
## Resources
|
| 273 |
|