Skip to main content

TorchInsight

TorchInsight is an enhanced PyTorch model analysis tool that provides functionality similar to torchinfo but with custom formatting and additional features.

Features

  • Detailed model structure visualization
  • Automatic FLOPS calculation with appropriate unit selection (K, M, G)
  • Support for input dimension specification without batch dimension
  • Support for long dtype specification for specific inputs
  • Analysis of various model architectures (CNN, Attention, Recommendation systems, etc.)
  • Colorized output for improved readability

Installation

pip install torchinsight

Quick Start

import torch
import torch.nn as nn
from torchinsight import analyze_model

# Create a simple model
class SimpleModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.conv1 = nn.Conv2d(3, 16, kernel_size=3, padding=1)
        self.pool = nn.MaxPool2d(2, 2)
        self.fc = nn.Linear(16 * 16 * 16, 10)
        
    def forward(self, x):
        x = self.pool(torch.relu(self.conv1(x)))
        x = x.view(-1, 16 * 16 * 16)
        x = self.fc(x)
        return x

# Create model instance
model = SimpleModel()

# Analyze model
summary = analyze_model(
    model,
    model_name="SimpleModel",
    input_dims=(3, 32, 32),  # Input dimensions (channels, height, width)
    batch_size=64,  # Batch size
)

# Print analysis results
print(summary)

Advanced Usage

TorchInsight supports multiple input formats and data types:

# Analyze model with multiple inputs
summary = analyze_model(
    model,
    model_name="ComplexModel",
    input_dims=[(13,), (5,)],  # Two inputs with dimensions (13,) and (5,)
    long_indices=[1],  # Second input (index 1) should be torch.long
    batch_size=128,  # Batch size
)

For more examples, see the examples directory.

Documentation

For complete documentation, visit:

Contributing

Contributions are welcome! Feel free to submit Pull Requests or create Issues.

License

This project is licensed under the MIT License - see the LICENSE file for details.

中文

Metadata

Release files for torchinsight 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for torchinsight 0.1.1
File Size Uploaded Provenance Actions
torchinsight-0.1.1.tar.gz 21.6 kB Without provenance Details for torchinsight-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for torchinsight 0.1.1
File Interpreter ABI Platform Actions
torchinsight-0.1.1-py3-none-any.whl Python 3 none any Details for torchinsight-0.1.1-py3-none-any.whl

Total release size: 35.3 kB

Release files / torchinsight-0.1.1.tar.gz

Download URL torchinsight-0.1.1.tar.gz
Size 21.6 kB
Tags Source
SHA-256 checksum
How to use checksums
0dec632027c32fe4a457b22b8a93ebac4313b13f3621b4c310adf107424cf301
BLAKE2b-256 checksum
How to use checksums
b547c1fc70a28186a227a4b9c3607e234f8fa6aeff324a0e135503eaa7368238
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.16

Release files / torchinsight-0.1.1-py3-none-any.whl

Download URL torchinsight-0.1.1-py3-none-any.whl
Size 13.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5f2a820fd6bb0afad6eb96e40bd7bff4448f33b010b4c85d0a02e92b59ee334e
BLAKE2b-256 checksum
How to use checksums
7a3034a2cabe3dac3b339b7d5ea2a4ec9e3b3d23ff8e490f2c1b345342e92d99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.10.16

Security for torchinsight 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page