print_torch
It is often overwhelming to print(tensor) which may flash your screen and you just don't get any information useful.
Instead, use pt(tensor) and it will give you the size, dtype, device, min, max, std, mean, whether has nan, etc. in one line.
>>> import torch
>>> from print_torch import pt
>>> tensor = torch.randn((2,3,4,5))
>>> pt(tensor)
tensor(shape=(2, 3, 4, 5), dtype=float32, min=-2.803, max=2.49, std=1.019, mean=-0.06855, data=[-0.8246, -1.135, 0.1368, 1.56, ... ], device="cpu") >>>
It also works for list of numbers and numpy tensors.
If you have a nested dict/list of pytorch/numpy tensors, you can also pt it, and it will list each element which may be again a tensor in one line.
For example, you can just pt(locals()) in your forward() function in the breakpoint to know all the stats of your local variables.
Don't hesitate to add this tool to your arsenal!
pip install print_torch
Metadata
Release files for print-torch 1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| print_torch-1.3.tar.gz | 4.1 kB | Without provenance | Details for print_torch-1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| print_torch-1.3-py3-none-any.whl | Python 3 | none | any | Details for print_torch-1.3-py3-none-any.whl |
Total release size: 8.5 kB
Release files / print_torch-1.3.tar.gz
| Download URL | print_torch-1.3.tar.gz |
|---|---|
| Size | 4.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
04cb325837d699f7a99b9cf064934bd0c6cb9dddc8476f51c77a2184df7e5b12
|
|
BLAKE2b-256 checksum How to use checksums |
c1c8d3c3d089926d7a5865bba3b2a97cc4e4c38a70f78ccaff26fbe5b28a7bc3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.10
|
Release files / print_torch-1.3-py3-none-any.whl
| Download URL | print_torch-1.3-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
fd0c4667261289347b494c8016ea6836946f79112e12c6c65296cb4c5c77fa27
|
|
BLAKE2b-256 checksum How to use checksums |
1096fbe749e07a92f6e2ea6d96c9e9e3361d230c5ec0b326549d0934b57192fd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.8.10
|
Security for print-torch 1.3
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.