Skip to main content

High-frequency monitoring of neural network representational dimensionality

Project description

Neural Dimensionality Tracker (NDT)

Tests codecov PyPI version Python 3.8+ License: MIT Code style: black

Neural Dimensionality Tracker (NDT) is a production-ready Python library for high-frequency monitoring of neural network representational dimensionality during training, enabling researchers and practitioners to track how internal representations evolve, detect discrete phase transitions (jumps), and gain mechanistic insights into the learning dynamics of deep neural networks across architectures (MLPs, CNNs, Transformers, Vision Transformers).

Features

  • Minimal Intrusion: Add dimensionality tracking to any PyTorch model with just 3 lines of code
  • Architecture-Agnostic: Automatic support for MLPs, CNNs, Transformers, and Vision Transformers
  • Multiple Metrics: Track 4 complementary dimensionality measures
  • Jump Detection: Automatically identify phase transitions during training
  • Rich Visualization: Built-in plotting with Matplotlib and interactive Plotly dashboards
  • Flexible Export: Save results as CSV, JSON, or HDF5
  • Production-Ready: Fully typed, tested (>90% coverage), and documented

Installation

pip install ndtracker

Quick Start

import torch.nn as nn
from ndt import HighFrequencyTracker

# Your model
model = nn.Sequential(
    nn.Linear(784, 512), nn.ReLU(),
    nn.Linear(512, 256), nn.ReLU(),
    nn.Linear(256, 10)
)

# Create tracker
tracker = HighFrequencyTracker(model, sampling_frequency=10)

# Training loop
for step, (x, y) in enumerate(dataloader):
    output = model(x)
    loss = criterion(output, y)
    loss.backward()
    optimizer.step()

    tracker.log(step, loss.item())  # One line!

# Analyze
results = tracker.get_results()
from ndt import plot_phases
plot_phases(results, metric="stable_rank")

Documentation

Reproducing the TDS Article Experiment

The repository includes a complete reproduction of the experiment described in the Towards Data Science article "I Measured Neural Network Training Every 5 Steps for 10,000 Iterations":

python examples/03_reproduce_tds_experiment.py

This script uses the exact specifications from the article:

  • Architecture: 784-256-128-10 (3-layer MLP)
  • Dataset: MNIST (60k train/10k test)
  • Optimizer: Adam (β1=0.9, β2=0.999)
  • Learning rate: 0.001, batch size: 64
  • Training: 8000 steps with measurements every 5 steps
  • Expected results: 3 distinct phases (collapse, expansion, stabilization)

Citation

If you use Neural Dimensionality Tracker in your research, please cite:

@software{marin2024ndt,
  author = {Marín, Javier},
  title = {Neural Dimensionality Tracker: High-Frequency Monitoring of Neural Network Training Dynamics},
  year = {2024},
  publisher = {GitHub},
  url = {https://github.com/Javihaus/ndt},
  version = {0.1.0}
}

Associated article:

@article{marin2025measuring,
  author = {Marín, Javier},
  title = {I Measured Neural Network Training Every 5 Steps for 10,000 Iterations: What High-Resolution Training Dynamics Taught Me About Feature Formation},
  journal = {Towards Data Science},
  year = {2025},
  month = {November},
  url = {https://towardsdatascience.com/}
}

License

MIT License - see LICENSE file for details

Author

Javier Marín

Acknowledgments

This work builds on research by:

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

ndtracker-1.0.2.tar.gz (41.4 kB view details)

Uploaded Source

Built Distribution

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

ndtracker-1.0.2-py3-none-any.whl (33.7 kB view details)

Uploaded Python 3

File details

Details for the file ndtracker-1.0.2.tar.gz.

File metadata

  • Download URL: ndtracker-1.0.2.tar.gz
  • Upload date:
  • Size: 41.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for ndtracker-1.0.2.tar.gz
Algorithm Hash digest
SHA256 46395d7379a46018527b4fdfdd76cbd95c807ff51ed540ed042d1e0b9a535d16
MD5 1eaa2c763efca9f58738a622610bf930
BLAKE2b-256 a4dc96b3e66b70752648c628d8069cda1cbc7f7148b9c448b29af2acca00bab0

See more details on using hashes here.

File details

Details for the file ndtracker-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: ndtracker-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 33.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for ndtracker-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 39e33e4a1925942111f340952acf96d100c4b7ca69c571da0e387c33bdeea8b5
MD5 7b6e1ce8c6357565e828f31a45558e51
BLAKE2b-256 daa11a4d9d87ecbafb99f50892bee5084b09fd6430e67b2cd3d0c4958a9bc8e1

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