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, count_parameters, 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)
total_params = count_parameters(m)
print("trainable params:", total_params)
What’s included
analyze(model, *example_inputs): records per-layer input/output shapesprint_report(result): prints a readable summarysuggest_fixes(records, error): helpful hints for common shape issuescount_parameters(model, trainable_only=True): total parameter count
Import name
The PyPI package is torch_model_inspector, but you import it as:
import torchinspect
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file torch_model_inspector-0.1.2.tar.gz.
File metadata
- Download URL: torch_model_inspector-0.1.2.tar.gz
- Upload date:
- Size: 5.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1cfaf0ec76f709e7757174f207e8af5ded03059e0615d3d9ca6c44a932d9034
|
|
| MD5 |
c26ac9357dac33c3757cbaa982c7bd84
|
|
| BLAKE2b-256 |
916b98a379b97cd87705bd78f7fac257fab3350f22be3abd4135d30afb4e6ce9
|
Provenance
The following attestation bundles were made for torch_model_inspector-0.1.2.tar.gz:
Publisher:
publish.yaml on ptkakaeitoe/torchinspect
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
torch_model_inspector-0.1.2.tar.gz -
Subject digest:
e1cfaf0ec76f709e7757174f207e8af5ded03059e0615d3d9ca6c44a932d9034 - Sigstore transparency entry: 893635275
- Sigstore integration time:
-
Permalink:
ptkakaeitoe/torchinspect@6d6ccb0a8a4582a109b8f4f22aeec47051610b85 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/ptkakaeitoe
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@6d6ccb0a8a4582a109b8f4f22aeec47051610b85 -
Trigger Event:
release
-
Statement type:
File details
Details for the file torch_model_inspector-0.1.2-py3-none-any.whl.
File metadata
- Download URL: torch_model_inspector-0.1.2-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43c1d4a617e9e3110d2ed341adba28463ab4f5e547322d7dabc958b065abaa28
|
|
| MD5 |
32a51f32dea60a597c9aee7c075e3ac3
|
|
| BLAKE2b-256 |
ba895f4cec5198333f61ad58de4bc05e3db19fe72977d44795723bebeedad896
|
Provenance
The following attestation bundles were made for torch_model_inspector-0.1.2-py3-none-any.whl:
Publisher:
publish.yaml on ptkakaeitoe/torchinspect
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
torch_model_inspector-0.1.2-py3-none-any.whl -
Subject digest:
43c1d4a617e9e3110d2ed341adba28463ab4f5e547322d7dabc958b065abaa28 - Sigstore transparency entry: 893635325
- Sigstore integration time:
-
Permalink:
ptkakaeitoe/torchinspect@6d6ccb0a8a4582a109b8f4f22aeec47051610b85 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/ptkakaeitoe
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@6d6ccb0a8a4582a109b8f4f22aeec47051610b85 -
Trigger Event:
release
-
Statement type: