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
NeuroSleep โ Light-Weight Sleep Stage Model
99,477 parameters, 93% accuracy (ฮบ=0.86) โ small enough for edge/wearable deployment, scoring Wake/N1/N2/N3/REM from 4-channel PSG.
Quick links: GitHub ยท Live Demo ยท Kaggle ยท Paper (coming soon)
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.
Quick Start
import torch
from huggingface_hub import hf_hub_download
from safetensors.torch import load_file
# Download checkpoint
path = hf_hub_download(
repo_id="shamique/Light-Weight-Neuromorphic-Sleep-Stage-Model",
filename="student_full_finetuned.safetensors",
)
# Load model (see source repo for ImprovedStudent class definition)
# https://github.com/shamiquekhan/neuromorphic-sleep-staging-pipeline
from sleep_staging.models.improved_student import ImprovedStudent
model = ImprovedStudent()
model.load_state_dict(load_file(path, device="cpu"))
model.eval()
# Run inference on preprocessed PSG data
# Input: [batch, 10, 4, 3000] โ 10 epochs, 4 channels, 3000 samples @ 100Hz
x = torch.randn(1, 10, 4, 3000) # replace with real data
with torch.inference_mode():
logits = model(x) # [1, 10, 5]
probs = torch.softmax(logits, dim=-1)
preds = probs.argmax(dim=-1) # [1, 10]
STAGE_NAMES = {0: "Wake", 1: "N1", 2: "N2", 3: "N3", 4: "REM"}
for i in range(10):
print(f"Epoch {i}: {STAGE_NAMES[preds[0, i].item()]} ({probs[0, i, preds[0, i]].item():.2%})")
Architecture
PSG Input (Fpz-Cz, Pz-Oz, EOG, EMG) [B, 10, 4, 3000]
โ
Multi-Resolution Stem (2 parallel Conv1d branches)
โ
Depthwise-Separable CNN (2 blocks)
โ
Parametric Gabor Feature Extraction (8 learnable filters)
โ
2-Layer GRU (hidden=64, 300s context)
โ
Linear(64โ5) + Softmax
โ
Wake / N1 / N2 / N3 / REM
| Module | Parameters |
|---|---|
| Stem (S+L) | 7,232 |
| Encoder (2 blocks) | 2,304 |
| Gabor FEB | 144 |
| GRU | 89,856 |
| Head | 325 |
| Total | 99,477 |
Input Format
- Sampling rate: 100 Hz
- Channels: Fpz-Cz, Pz-Oz, EOG, EMG
- Epoch length: 30 seconds (3000 samples)
- Sequence length: 10 epochs
- Shape:
[batch, 10, 4, 3000] - Preprocessing: 0.5โ35 Hz bandpass โ 50 Hz notch โ z-score normalization
Output Labels
| Index | Stage | Description |
|---|---|---|
| 0 | Wake | Awake state |
| 1 | N1 | Light sleep |
| 2 | N2 | Intermediate sleep |
| 3 | N3 | Deep sleep |
| 4 | REM | Rapid eye movement sleep |
Evaluation (15 subjects, 4-fold subject-level CV)
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.
| Metric | Value |
|---|---|
| Accuracy | 93.0% ยฑ 1.0% |
| Cohen's Kappa | 0.861 ยฑ 0.027 |
| Macro F1 | 0.794 ยฑ 0.036 |
| Weighted F1 | 0.935 ยฑ 0.007 |
| Geometric Mean Recall | 0.816 ยฑ 0.043 |
Per-Class Performance
| Stage | F1 | Precision | Recall | Support |
|---|---|---|---|---|
| Wake | 0.982 ยฑ 0.010 | 0.997 | 0.968 | ~3,832 |
| N1 | 0.455 ยฑ 0.157 | 0.416 | 0.525 | ~116 |
| N2 | 0.874 ยฑ 0.044 | 0.916 | 0.841 | ~421 |
| N3 | 0.856 ยฑ 0.066 | 0.810 | 0.920 | ~446 |
| REM | 0.803 ยฑ 0.063 | 0.714 | 0.936 | ~441 |
Honest assessment: Overall accuracy (93%) is strong, but N1 recall is only 52.5% โ the model frequently misclassifies N1 epochs as Wake or N2. This is expected given N1 is only 3.4% of the dataset. REM precision (71.4%) reflects physiological overlap with N2.
Preprocessing
The model expects preprocessed data:
- Bandpass filter: 0.5โ35 Hz
- Notch filter: 50 Hz
- Normalization: z-score per channel
- Epoching: 30-second windows at 100 Hz
See the source repo for the full preprocessing pipeline.
Training Details
- Dataset: Sleep-EDF Expanded (15 subjects, PhysioNet)
- Optimizer: AdamW (lr=3e-4, weight_decay=1e-2)
- Epochs: 15
- Class weights: N1=2x, REM=2x
- Supervision: All-position (every epoch in 10-epoch window)
- Gradient clipping: max_norm=1.0
- Class distribution: Wake=68.8%, N1=3.4%, N2=16.4%, N3=5.0%, REM=6.4%
LoRA Adaptation (Parameter-Efficient Fine-Tuning)
The model supports LoRA (Low-Rank Adaptation) for efficient fine-tuning on new datasets without updating all 99K parameters.
LoRA Configuration
| Property | Value |
|---|---|
| Target modules | head (classification layer) |
| Rank | 8 |
| Alpha | 16 |
| Scaling | 2.0 |
| Trainable params | 552 (0.55% of total) |
Apply LoRA
from peft import LoraConfig, get_peft_model
lora_config = LoraConfig(
r=8,
lora_alpha=16,
target_modules=["head"],
lora_dropout=0.05,
bias="none",
)
model = ImprovedStudent()
model.load_state_dict(load_file(ckpt_path, device="cpu"))
model = get_peft_model(model, lora_config)
model.print_trainable_parameters()
# trainable params: 552 || all params: 99,477 || trainable%: 0.55%
LoRA vs Full Fine-Tuning
| Method | Trainable Params | Accuracy | Macro F1 |
|---|---|---|---|
| Frozen Base | 0 | 83.0% | 0.644 |
| LoRA r=8 | 552 | 89.1% | 0.686 |
| Full Fine-Tuning | 99,477 | 93.0% | 0.794 |
LoRA achieves 94% of full fine-tuning accuracy with 0.55% of the parameters. See the source repo for LoRA training scripts.
Intended Use
- Research and educational sleep-stage classification
- Benchmarking and comparison with other sleep staging methods
- Edge deployment on resource-constrained devices (MCUs, wearables)
- Transfer learning via LoRA for new sleep datasets
Limitations
- Not clinically validated โ do not use for diagnosis or clinical decision-making
- N1 classification is challenging (F1=0.455) due to brief, transitional light sleep
- Trained on Sleep-EDF Expanded (15 subjects); generalizability should be validated
- Requires 4-channel PSG (Fpz-Cz, Pz-Oz, EOG, EMG) โ single-channel EEG not supported
- Class distribution is Wake-dominant (68.8%) from untrimmed recordings
Resources
| Resource | Link |
|---|---|
| Source Code | GitHub |
| Live Demo | Hugging Face Space |
| Reproduce | Kaggle Notebook |
| Model Weights | This page |
Citation
@project{neurosleep_2026,
title={NeuroSleep: Light-Weight Sleep Stage Scoring},
author={Kaushik, P. and Vora, S. and Bhatt, S. and Khan, S. and Lone, A.J.},
year={2026},
institution={VIT Bhopal University}
}
Download Counting
Hugging Face counts downloads per unique file. For this model, the primary tracked file is student_full_finetuned.safetensors. Each HTTP request (GET or HEAD) to this file counts as one download. Clone operations that download all files are counted once per file.
For granular download analytics (unique users, CI/CD filtering), see Publisher Analytics.
Evaluation results
- Accuracy on Sleep-EDF Expanded (15 subjects, PhysioNet)test set self-reported0.930
- Cohen's Kappa on Sleep-EDF Expanded (15 subjects, PhysioNet)test set self-reported0.861
- Macro F1 on Sleep-EDF Expanded (15 subjects, PhysioNet)test set self-reported0.794
- Weighted F1 on Sleep-EDF Expanded (15 subjects, PhysioNet)test set self-reported0.935
- N1 F1 on Sleep-EDF Expanded (15 subjects, PhysioNet)test set self-reported0.455
- REM F1 on Sleep-EDF Expanded (15 subjects, PhysioNet)test set self-reported0.803