A very lightweight and minimalistic output shape examiner of layers and models.
Project description
output-shape
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
Project details
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 output_shape-0.0.3.tar.gz.
File metadata
- Download URL: output_shape-0.0.3.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea408cf616be701c02e7031c7ce68b61b3b62919c8e594c512c19444f9fe301c
|
|
| MD5 |
c10cb09ad0d564095df8413e17eb89df
|
|
| BLAKE2b-256 |
a07fdf3bf13b10510980f64eaa2b57c4c061d7ea1c6c7b37044460e80ef17516
|
File details
Details for the file output_shape-0.0.3-py3-none-any.whl.
File metadata
- Download URL: output_shape-0.0.3-py3-none-any.whl
- Upload date:
- Size: 3.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d2bbe4e569a7dbcfb95103ff510b8682c48ae8318d2b2f67367a12527075af3
|
|
| MD5 |
ca23a8625f826a89ea3fe9d5935683b0
|
|
| BLAKE2b-256 |
e32f8598b65a7f029943860cfaac66700e385616a4d6cdb5c28cde3342adf1e1
|