Skip to main content

A Layer-Wise Diagnostic Framework for Neural Network Robustness

Project description

DeepDrift

DOI License: MIT PyTorch

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)

Dashboard

🚀 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.

Observer Logic

  • ⚠️ 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

  1. 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)"
  1. 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.

  1. DeepDrift: A Layer-Wise Diagnostic Framework for Neural Network Robustness (2025)

    • The foundational paper describing the framework and metrics.
  2. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

deepdrift-0.2.1.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

deepdrift-0.2.1-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

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

Hashes for deepdrift-0.2.1.tar.gz
Algorithm Hash digest
SHA256 e3ed19181fde7b81bc4357167ac7d01be3799954b9a1982f4ec24dd703cfc61c
MD5 632de080423a6bd8b8d1e71bc226e579
BLAKE2b-256 16ddf72742a7eff5ae240d566c02a6a30225a880a0c5c33327a8ed5c199ecb19

See more details on using hashes here.

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

Hashes for deepdrift-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8d1643a2763995cc40dc3edeadfec58d4318e7387c9ad91a5f5bfc0a64019a43
MD5 0ee354f183d24a71b4f77a54a5585492
BLAKE2b-256 e45674b2641b652bc80b0ae8c477fd4eb8a9f7262040edd1e1c1b18ff8c0cf4e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page