Skip to main content

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.

Python 3.7+ License: MIT

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{layerlens,
  title = {LayerLens: Layer-by-Layer Explainability for Deep Learning},
  author = {navi-04},
  year = {2025},
  url = {https://github.com/navi-04/LayerLens}
}

D:/GitHub/LayerLens/.venv/Scripts/python.exe -m jupyter notebook mnist_demo.ipynb

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

layerlens-0.1.1.tar.gz (705.2 kB view details)

Uploaded Source

Built Distribution

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

layerlens-0.1.1-py3-none-any.whl (129.9 kB view details)

Uploaded Python 3

File details

Details for the file layerlens-0.1.1.tar.gz.

File metadata

  • Download URL: layerlens-0.1.1.tar.gz
  • Upload date:
  • Size: 705.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for layerlens-0.1.1.tar.gz
Algorithm Hash digest
SHA256 66ab61a49a1db522d6c9edd6b90cd84e74dc0b90c0314e4b1ae4d8018ecfe9ea
MD5 0e5d4d9f3a44fbcb5aca71d378706361
BLAKE2b-256 86c35b941f52094d11d1a6d2498c8eabac6756b88239091946635ae56b189edd

See more details on using hashes here.

File details

Details for the file layerlens-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: layerlens-0.1.1-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

Hashes for layerlens-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 01b74188bb19ba34e532a465feb5453a47d6ae8d543cd336d2e0ff4ea61a5bb6
MD5 052183a6abac895f38a11f49ae9895a5
BLAKE2b-256 744073436f75926832cdabc3a301478d92b494dea7aff90be01b7d356ddf62a6

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