Skip to main content

Lightweight utilities for inspecting PyTorch model shapes.

Project description

torchinspect

Lightweight utilities for inspecting PyTorch model shapes and common mismatch errors.

Install

From PyPI (recommended):

pip install torch_model_inspector

Local editable install (for development):

pip install -e .

Usage

import torch
import torch.nn as nn
from torchinspect import analyze, print_report

class BadModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.conv = nn.Conv2d(3, 8, kernel_size=3, stride=1, padding=1)
        self.fc = nn.Linear(16, 10)  # intentionally wrong

    def forward(self, x):
        x = self.conv(x)
        return self.fc(x)

m = BadModel()
x = torch.randn(2, 3, 32, 32)

res = analyze(m, x)
print_report(res, last_n=20)

What’s included

  • analyze(model, *example_inputs): records per-layer input/output shapes
  • print_report(result): prints a readable summary
  • suggest_fixes(records, error): helpful hints for common shape issues

Import name

The PyPI package is torch_model_inspector, but you import it as:

import torchinspect

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

torch_model_inspector-0.1.0-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file torch_model_inspector-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for torch_model_inspector-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5f948dc05cf11223b9048ca06383ed331fd7887b66f581ba729c81c5ea521551
MD5 d22bcf53bdca3e997194c787275232cb
BLAKE2b-256 66934ad093b3742bb4407d2254a748a615ae675127723ce3083cc2589c192d57

See more details on using hashes here.

Provenance

The following attestation bundles were made for torch_model_inspector-0.1.0-py3-none-any.whl:

Publisher: publish.yaml on ptkakaeitoe/torchinspect

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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