A library for layer-by-layer explainability of deep learning models
Project description
LayerLens
LayerLens is a powerful library for layer-by-layer explainability of deep learning models. It provides insights into how models make decisions by analyzing the behavior of individual layers.
Features
- Layer-wise Explanation: Generate surrogate models for each layer to explain its behavior
- Hierarchical Insights: Stitch together layer explanations to understand the full model
- Interactive Visualization: Explore model behavior through an intuitive dashboard
- Production Monitoring: Detect drift and localize failures in deployed models
- Framework Agnostic: Works with PyTorch, TensorFlow, and other major frameworks
- Comprehensive Testing: Full test suite ensuring reliability and stability
Installation
From Source (Recommended)
# Clone the repository
git clone https://github.com/your-username/LayerLens.git
cd LayerLens
# Install dependencies
pip install -r requirements.txt
# Install LayerLens
pip install -e .
Via pip (when published)
pip install layerlens
Note: You'll also need to install at least one ML framework:
pip install torch # For PyTorch support
# or
pip install tensorflow # For TensorFlow support
Quick Start
from layerlens import Explainer
import numpy as np
# Load your trained model (PyTorch or TensorFlow)
# model = ... (your trained model)
# Create a LayerLens explainer
explainer = Explainer(model)
# Prepare your data
input_data = np.random.rand(10, 28, 28, 1) # Example
# Generate explanations
explanation = explainer.explain(input_data)
# Visualize the results
explainer.visualize(explanation, output_dir='./explanations')
# Monitor for drift (production use)
explainer.monitor(input_data)
Running Examples
Try the MNIST demo to see LayerLens in action:
cd examples
jupyter notebook mnist_demo.ipynb
Verification
Verify your installation is working correctly:
python tests/verify_installation.py
Run the full test suite:
pytest tests/
Documentation
For detailed documentation and usage guides:
- USAGE.md - Complete usage guide with examples
- docs/ - Technical documentation and theory
- examples/ - Jupyter notebook demos
Project Structure
LayerLens/
├── layerlens/ # Main package
│ ├── core/ # Core explainability engine
│ ├── visualization/ # Interactive dashboards and plots
│ ├── monitoring/ # Production monitoring tools
│ └── utils/ # Helper utilities
├── examples/ # Demo notebooks
├── tests/ # Test suite
└── docs/ # Documentation
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Citation
If you use LayerLens in your research, please cite:
@software{layerlens2024,
title = {LayerLens: Layer-by-Layer Explainability for Deep Learning},
author = {LayerLens Team},
year = {2024},
url = {https://github.com/your-username/LayerLens}
}
D:/GitHub/LayerLens/.venv/Scripts/python.exe -m jupyter notebook mnist_demo.ipynb
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 layerlens-0.1.0.tar.gz.
File metadata
- Download URL: layerlens-0.1.0.tar.gz
- Upload date:
- Size: 700.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4c4611dd040a6bc2019575dec436f35de8ab18813f25943402f9f8dd12633a8b
|
|
| MD5 |
e727171f6c1b7e2262d0ff77f93e0042
|
|
| BLAKE2b-256 |
fd33f0d1702e4e4f5e69fa2a8035b39c3d80b6a9b9a629bad0ae492c1ae411ef
|
File details
Details for the file layerlens-0.1.0-py3-none-any.whl.
File metadata
- Download URL: layerlens-0.1.0-py3-none-any.whl
- Upload date:
- Size: 129.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5603e9ea5ae8357c62fbdd36267ef8464d82a7b529555927392783d49d528db9
|
|
| MD5 |
5eda3a7912e31fca7ac4a1eaed38b85f
|
|
| BLAKE2b-256 |
519c0e8c19cd72bd4c215c6430aca3bf7c13b6992c4e2db0cffcac7c4c6ae4cc
|