"Edge-1DCNN-LSTM: A Lightweight Hybrid Model for Time-Series Anomaly Detection in Edge Sensing Devices"
reproduce_paper/
├── README.md # This file
├── requirements.txt # Python dependencies
├── models/
│ ├── __init__.py # Model registry (9 models) + factory functions
│ ├── edge_1dcnn_lstm.py # Proposed Edge-1DCNN-LSTM model
│ ├── vanilla_lstm.py # Baseline: Vanilla LSTM
│ ├── vanilla_1dcnn.py # Baseline: Vanilla 1D-CNN
│ ├── standard_1dcnn_lstm.py # Comparison: Standard 1DCNN-LSTM
│ ├── lightweight_1dcnn_lstm.py # Comparison: Lightweight 1DCNN-LSTM
│ └── end_edge_collaborative.py # End-edge collaborative framework
├── training/
│ ├── trainer.py # FocalLoss + train_model (Adam, early stopping)
│ ├── pruner.py # L1 unstructured pruning + fine-tuning
│ └── quantizer.py # Dynamic INT8 quantization
├── data/
│ ├── dataset_base.py # Unified data loader (Simulated + FD001)
│ └── prepare_datasets.py # Data generation (simulate) & conversion (FD001)
└── results/ # Experiment output (auto-created)
# Install dependencies
pip install -r requirements.txt
# Prepare datasets (auto-generates simulated data; FD001 requires manual download)
python -m reproduce_paper.data.prepare_datasetsThe simulated dataset (50K samples, 15% anomaly) is generated from a fixed seed (seed=42) and placed at datasets/simulate/dataset.json.
For NASA FD001, the script will attempt an automatic download. If that fails, please:
- Download C-MAPSS FD001 from NASA Prognostics Repository
- Place
train_FD001.txtindatasets/NASA/ - Re-run:
python -m reproduce_paper.data.prepare_datasets --fd001
Compares 9 models on two datasets:
| ID | Model | Category |
|---|---|---|
| 1 | Pure LSTM | Baseline |
| 2 | Pure 1D-CNN | Baseline |
| 3 | Standard 1DCNN-LSTM | Comparison |
| 4 | Lightweight 1DCNN-LSTM | Comparison |
| 5 | Pruned 1DCNN-LSTM (75% sparsity) | Comparison |
| 6 | Quantized 1DCNN-LSTM (dynamic INT8) | Comparison |
| 7 | End-Edge Collaborative | Framework |
| 8 | Ours (Edge-1DCNN-LSTM, FP32) | Proposed |
| 9 | Ours (Edge-1DCNN-LSTM, INT8) | Proposed |
Expected Results (Simulated Dataset):
| Model | F1 Score | AUC |
|---|---|---|
| Ours (FP32) | ~0.97-0.99* | ~0.995 |
| Ours (INT8) | ~0.96-0.99* | ~0.993 |
* F1 score varies across runs due to random data splitting (seed=42). AUC is highly stable. The paper reports F1=0.994 from a specific training run with optimal threshold tuning.
Compares FP32 vs INT8 hybrid quantization on the proposed model:
- INT8 mixed-precision: LSTM layers → INT8, CNN/BatchNorm layers → FP32 (LSTM dominates 99.1% of parameters)
- Expected: ~61% model size reduction, <0.5% F1 degradation
- Note: The 29.5% inference speedup reported in the paper was measured on Raspberry Pi 4B. On x86 CPUs, dynamic quantization may show minimal speedup. Model size reduction is hardware-independent.
Evaluates the sentinel-based collaborative framework with threshold sweep (0.5–0.95):
- Sentinel: Vanilla LSTM (lightweight, on edge device)
- Full Model: Edge-1DCNN-LSTM (on cloud/edge server)
- Expected (threshold=0.9): System F1≈0.990, ~72% energy saving*, ~27% wake rate
- *: Energy saving is estimated using E = P × T with power values from Raspberry Pi 4B (sentinel: 0.3W, full: 5.0W). Actual values depend on the target edge hardware.
Input (B, seq_len, 1)
→ Conv1d(1, 16, k=3, p=1) → BatchNorm → ReLU → MaxPool(k=2)
→ LSTM(input=16, hidden=32, layers=2, dropout=0.2)
→ Take last hidden state → Dropout(0.2) → FC(32, 1) → Sigmoid
Parameters: ~12,700 (with input_dim=1) | ~14,900 (paper-reported with overhead)
| Parameter | Simulated | FD001 |
|---|---|---|
| Epochs | 100 | 200 |
| Learning Rate | 0.001 | 0.001 |
| Batch Size | 64 | 64 |
| Optimizer | Adam | Adam |
| Scheduler | ReduceLROnPlateau | ReduceLROnPlateau |
| Early Stopping | patience=15 | patience=25 |
| Loss | BCELoss | FocalLoss (alpha=0.75, gamma=2) |
| Sequence Length | 10 | 10 |
| Train/Val/Test | 70/15/15 | 70/15/15 |
| : Sentinel confidence = | p - 0.5 | × 2; low-confidence samples forwarded to full model. |
This repository contains the preliminary experimental code corresponding to the submitted manuscript Edge-1DCNN-LSTM: A Lightweight Hybrid Model for Time-Series Anomaly Detection in Edge Sensing Devices.
-Generalization Validation: Add pre-trained models and testing scripts for additional public industrial time-series anomaly detection datasets (e.g., SMD, SWaT, WADI)
-Hardware Deployment Optimization: Complete the hardware-aware INT8 optimization code for ultra-low-power MCUs (e.g., ESP32, STM32) with dedicated acceleration units
-Documentation Improvement: Add a detailed step-by-step deployment tutorial for terminal-edge hardware setup, and expand the hyperparameter tuning guide
-Code Refactoring: Refactor the codebase for better readability and modularity, and add Python package installation support.