Skip to main content

output-shape

PyPI version

A very lightweight and minimalistic output shape examiner of layers and models.

** Currently working for PyTorch models only. Keras / Jax soon! **

Installation

pip install output-shape

Usage

Decorate the forward method with @output_shape, then use either option:

import torch
from output_shape import output_shape, debug_shapes

class Model(torch.nn.Module):
    def __init__(self, debug=False):
        super().__init__()
        self.debug = debug
        ...

    @output_shape
    def forward(self, x):
        ...

# Option 1: Context manager
model = Model()
with debug_shapes():
    model(torch.randn(2, 1, 128, 128))

# Option 2: Instance flag
model = Model(debug=True)
model(torch.randn(2, 1, 128, 128))
Input                           torch.Size([2, 1, 128, 128])
Conv2d                          torch.Size([2, 768, 8, 8])
PatchEmbed                      torch.Size([2, 64, 768])
LayerNorm                       torch.Size([2, 13, 768])
Linear                          torch.Size([2, 13, 2304])
Linear                          torch.Size([2, 13, 768])
Dropout                         torch.Size([2, 13, 768])
Attention                       torch.Size([2, 13, 768])
PreNorm                         torch.Size([2, 13, 768])
LayerNorm                       torch.Size([2, 13, 768])
Linear                          torch.Size([2, 13, 3072])
GELU                            torch.Size([2, 13, 3072])
Dropout                         torch.Size([2, 13, 3072])
Linear                          torch.Size([2, 13, 768])
Dropout                         torch.Size([2, 13, 768])
FeedForward                     torch.Size([2, 13, 768])
PreNorm                         torch.Size([2, 13, 768])
Transformer                     torch.Size([2, 13, 768])
LayerNorm                       torch.Size([2, 13, 768])
Linear                       

Metadata

Release files for output-shape 0.0.4

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

Source distribution (sdist)

Source distribution for output-shape 0.0.4
File Size Uploaded Provenance Actions
output_shape-0.0.4.tar.gz 3.6 kB Without provenance Details for output_shape-0.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for output-shape 0.0.4
File Interpreter ABI Platform Actions
output_shape-0.0.4-py3-none-any.whl Python 3 none any Details for output_shape-0.0.4-py3-none-any.whl

Total release size: 7.2 kB

Release files / output_shape-0.0.4.tar.gz

Download URL output_shape-0.0.4.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
89160a2bbcfdb82de59860610c5a76b25df4930a8ffa1e50aab3d33a0027ce6c
BLAKE2b-256 checksum
How to use checksums
e81d4a46c63237cbb7844be163e4675b1a8a6707b66b98b66a1812ce94c54590
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.18

Release files / output_shape-0.0.4-py3-none-any.whl

Download URL output_shape-0.0.4-py3-none-any.whl
Size 3.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a9e66e997aea594efcad7b8762c68f83da8678cfd122028b9bc35fc5df0355ce
BLAKE2b-256 checksum
How to use checksums
41e307bd12d27730c743a763d0442c64358b1d7335827c98e4cb3e85cbdd6dc1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.18

Security for output-shape 0.0.4

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.

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