TensorHue – a tensor visualization library

Debugging tensor contents can be quite challenging. For example, you might need to locate a row with extreme values hidden within a string of numbers like [[2.57e-6, 1.04e-3, …, 4.23e-2, 8.34e-3]]. If there was a mistake in preprocessing your image dataset, such as accidental transposition of tensors, it becomes even harder to identify the issue. Once tensors are converted from Pillow, viewing them directly can be difficult, especially if you’re connected via SSH and can’t use Image.show().

To address these challenges, I created TensorHue: GitHub - epistoteles/TensorHue: TensorHue is a Python library that allows you to visualize tensors right in your console, making understanding and debugging tensor contents easier.

TensorHue is an open-source Python library designed for ease of use. It allows you to display tensors (and images) directly in the console with just one line of code:

import tensorhue

TensorHue supports PyTorch, JAX, TensorFlow, Numpy, and Pillow, as well as libraries that depend on them (e.g., torchvision, transformers). It helps you preview image datasets in your console, view color-coded confusion matrices without matplotlib, understand the distribution of your activations, weights, or logits, and more.

TensorHue is still a work in progress—please provide feedback, report issues, contribute with PRs, or give it a star :slight_smile:

5 Likes

I second you, but please avoid hijacking and patching the PyTorch codebase, as it creates significant technical debt for users in the medium and long term.

Otherwise, the concept seems excellent.

5 Likes

Please avoid modifying PyTorch’s types—just use tensorhue.viz(array) instead. Other than that, it looks pretty cool, and I’d be interested in using it.

4 Likes

This would be cleaner. Without having looked into the source, redefining or encapsulating the tensor object may lead to unforeseen issues.

4 Likes

I don’t quite understand it either; from the examples, it seems like just an imshow wrapper. The torchshow library that someone else mentioned appears to be more useful.

After examining the code, I see it’s not an imshow wrapper but prints the tensor as text. That’s an interesting feature, though I don’t have a need for it at the moment.

3 Likes

Hi, I can’t see the project’s license at Github or Pypi. Do you intend to keep it all rights reserved?

3 Likes