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
output_shape-0.0.4.tar.gz
(3.6 kB
view details)
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.4.tar.gz.
File metadata
- Download URL: output_shape-0.0.4.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
89160a2bbcfdb82de59860610c5a76b25df4930a8ffa1e50aab3d33a0027ce6c
|
|
| MD5 |
9340151e5d080d5877a7f285572f83bb
|
|
| BLAKE2b-256 |
e81d4a46c63237cbb7844be163e4675b1a8a6707b66b98b66a1812ce94c54590
|
File details
Details for the file output_shape-0.0.4-py3-none-any.whl.
File metadata
- Download URL: output_shape-0.0.4-py3-none-any.whl
- Upload date:
- Size: 3.7 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 |
a9e66e997aea594efcad7b8762c68f83da8678cfd122028b9bc35fc5df0355ce
|
|
| MD5 |
54f92650eefb690e4605dd6c1b7824eb
|
|
| BLAKE2b-256 |
41e307bd12d27730c743a763d0442c64358b1d7335827c98e4cb3e85cbdd6dc1
|