skillfed

lovely-tensors

❤️ Lovely Tensors

lovely-tensors v0.1.22 75.9K downloads/30d#14,666 on PyPI1,391
Permissive license MIT Active released

What it is and what it does

Lovely Tensors replaces PyTorch's default tensor repr with a compact, human-readable summary that shows shape, element count, memory footprint, value range, mean, standard deviation, and a histogram—all in one line. It detects and flags NaN, Inf, and all-zero tensors, and works with named dimensions and gradient tracking. The package monkey-patches torch.Tensor's display methods so the improved output appears automatically in notebooks and REPLs without changing your code.

It is designed for interactive debugging and exploration, not for production logging. The summary format is stable across tensor operations, making it easy to spot data anomalies during model development. It also provides optional verbose and plain-text modes, and a `.deeper` method to recursively inspect nested tensor structures.

Use it for:

  • Debugging neural network activations in Jupyter notebooks without scrolling through thousands of raw values
  • Quickly spotting NaN or Inf propagation during training by inspecting intermediate tensors
  • Verifying tensor shapes and memory usage at a glance during model prototyping
  • Inspecting gradient statistics after backpropagation to detect gradient explosion or vanishing
  • Exploring multi-dimensional data (e.g., image batches) by recursively drilling into sub-tensors with `.deeper`

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Monkey-patches PyTorch tensors to display human-readable summaries with statistics, histograms, and anomaly detection instead of raw numerical dumps.

Yes. Low install friction, no security issues, permissive license, and active maintenance make it a safe addition. If you work with PyTorch in notebooks or interactive environments, the quality-of-life improvement from readable tensor summaries justifies the minimal dependency footprint. Not essential for production code, but valuable for development and debugging.

Install

lovely-tensors on PyPI

pip

pip install lovely-tensors

uv

uv add lovely-tensors

poetry

poetry add lovely-tensors

Installing lovely-tensors

Before you install

Low friction: pure Python wheel with only torch and lovely-numpy as runtime dependencies. Active maintenance with recent releases; marked Alpha but in use across top-tier projects.

License in practice

MIT license permits unrestricted use, modification, and distribution with minimal attribution requirements.

Quickstart

pip install lovely-tensors

import lovely_tensors as lt
import torch

lt.monkey_patch()

t = torch.randn(3, 196, 196)
print(t)  # Now shows: tensor[3, 196, 196] n=115248 x∈[...] μ=... σ=...

Verify before relying

  • Whether monkey-patching persists across notebook restarts or requires re-import in each session
  • Performance impact when working with very large tensors (gigabyte scale)
  • Compatibility with custom tensor subclasses or third-party PyTorch extensions

Package facts

License MIT (permissive)
Python support supports the current Python release (>=3.8)
Install friction low — pure-Python wheel
Runtime dependencies 2 — torch, lovely-numpy
Maintenance actively maintained — 156 days since the last release
Last repo commit
First released
Downloads 75,939/month — #14,666 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: lovely_tensors-0.1.22-py3-none-any.whl

Keywords: jupyter, pytorch, tensor, visualisation

Development Status :: 3 - AlphaIntended Audience :: DevelopersNatural Language :: EnglishProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: Only

Tags

pytorch tensor visualizationtorch tensor debuggingtensor summary statisticspytorch repr improvementtensor inspection tool
pytorch-debuggingjupyter-friendlytensor-inspection

More Artificial Intelligence packages