A Layer-Wise Diagnostic Framework for Neural Network Robustness
Project description
DeepDrift
A Layer-Wise Diagnostic Framework for Neural Network Robustness.
"Stop guessing why your model failed. See exactly where it broke."
DeepDrift is an unsupervised diagnostic tool that acts like an MRI scan for your neural network. Instead of just monitoring output accuracy (which is a lagging indicator), DeepDrift analyzes how data representations evolve layer-by-layer in real-time.
It allows you to distinguish between:
- Sensor Failure (High drift at input layers)
- Geometric Collapse (Drift accumulation in deep layers)
- Spurious Correlations (Anomalies in mid-level features)
🚀 Key Features
- Unsupervised: No labeled OOD data required. Works in production.
- Lightweight: < 1% inference overhead.
- Interpretability: Maps drift to network depth ($z$-axis).
- AI Doctor: Built-in heuristics to classify failure modes.
🧠 Under the Hood: Predictive Monitoring
DeepDrift isn't just a threshold check. It implements a stateful Finite State Machine (FSM) with hysteresis and trend analysis to prevent alert fatigue.
- ⚠️ Early Warning (Yellow): Detects rapid drift acceleration ($\beta$-slope) before the critical threshold is breached.
- 🔴 Critical Alert (Red): Triggers when structural integrity is compromised.
- 🟢 Hysteresis Recovery: The alert stays active until the system stabilizes significantly below the threshold, preventing flickering alarms.
📦 Installation
git clone https://github.com/Eutonics/DeepDrift.git
cd DeepDrift
pip install .
⚡ Quick Start
- Real-time Monitoring (Production Mode) Use the stateful monitor to track model health with hysteresis and trend detection. codePython
import torch
import torchvision.models as models
from deepdrift import DeepDriftMonitor, ObserverConfig
# 1. Load your model
model = models.resnet18(pretrained=True)
model.eval()
# 2. Configure Sensitivity
# theta_slope: Detects rapid drift acceleration
# theta_high: Critical alert threshold (Sigma)
config = ObserverConfig(theta_high=3.0, theta_slope=0.05, window_size=20)
monitor = DeepDriftMonitor(model, arch_name='ResNet-18', drift_config=config)
# 3. Calibrate on clean data (establish baseline)
# monitor.calibrate(train_loader, max_batches=50)
# 4. Monitoring Loop
# status, alerts = monitor.step(incoming_batch)
# if alerts:
# for alert in alerts:
# print(alert)
# # Output: "⚠️ WARNING [Mid]: Rapid Drift Detected (Slope 0.045)"
# # Output: "🔴 ALERT [IR]: Threshold Breach (3.2 >= 3.0)"
- Static Diagnosis (Research Mode) Analyze a single batch to get a spectral signature and diagnosis. codePython
from deepdrift import diagnose_drift, plot_drift_profile
# ... (after calibration) ...
# Get raw profile
drift_profile = monitor.step(ood_batch)[0] # Extract drift values
# Get Diagnosis
diagnosis = diagnose_drift([d['drift'] for d in drift_profile.values()])
print(f"Diagnosis: {diagnosis}")
# Output: "WARNING: Avalanche Effect (Geometric Failure)"
📚 Research & Publications DeepDrift is backed by research on Renormalization Group theory in Deep Learning.
-
DeepDrift: A Layer-Wise Diagnostic Framework for Neural Network Robustness (2025)
- The foundational paper describing the framework and metrics.
-
Spatial Dynamics of Memorization in Diffusion Models (2025)
- Application of DeepDrift to discover the "Burning Bottleneck" phenomenon in U-Nets.
📄 Citation If you use DeepDrift in your research, please cite: codeBibtex
@article{evtushenko2025deepdrift,
title={DeepDrift: A Layer-Wise Diagnostic Framework for Neural Network Robustness},
author={Evtushenko, Alexey},
journal={arXiv preprint},
doi={10.5281/zenodo.18086612},
year={2025}
}
License This project is licensed under the MIT License. codeCode
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file deepdrift-0.2.1.tar.gz.
File metadata
- Download URL: deepdrift-0.2.1.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e3ed19181fde7b81bc4357167ac7d01be3799954b9a1982f4ec24dd703cfc61c
|
|
| MD5 |
632de080423a6bd8b8d1e71bc226e579
|
|
| BLAKE2b-256 |
16ddf72742a7eff5ae240d566c02a6a30225a880a0c5c33327a8ed5c199ecb19
|
File details
Details for the file deepdrift-0.2.1-py3-none-any.whl.
File metadata
- Download URL: deepdrift-0.2.1-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d1643a2763995cc40dc3edeadfec58d4318e7387c9ad91a5f5bfc0a64019a43
|
|
| MD5 |
0ee354f183d24a71b4f77a54a5585492
|
|
| BLAKE2b-256 |
e45674b2641b652bc80b0ae8c477fd4eb8a9f7262040edd1e1c1b18ff8c0cf4e
|