tensorguard
Science Score: 44.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
✓CITATION.cff file
Found CITATION.cff file -
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Academic email domains
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (8.9%) to scientific vocabulary
Repository
Basic Info
- Host: GitHub
- Owner: lengstrom
- Language: Python
- Default Branch: main
- Size: 1.41 MB
Statistics
- Stars: 9
- Watchers: 2
- Forks: 0
- Open Issues: 0
- Releases: 0
Metadata Files
README.md
tensorguard
Pretty runtime typechecking for PyTorch and Numpy tensors!
Install
git clone git@github.com:lengstrom/tensorguard.git
pip install -e tensorguard
Example usage
As a decorator: ```python from tensorguard import tensorguard, Tensor as T import torch as ch
@tensorguard def inference(x: T(['bs', 3, 224, 224], 'float16', 'cpu'), y: T(['bs'], 'int64')): pass
make examples with wrong dtype
x = ch.ones(128, 3, 224, 224, dtype=ch.float32)
make labels with wrong batch size
y = ch.ones(256)
checks happen at runtime with @tensorguard decorator
inference(x, y) ```
As a standalone assertion: ```python from tensorguard import tensorcheck x = ch.randn(4, 4).to(dtype=ch.float32) x_expected = Tensor([4, 4])
check one at once
tensorcheck(x, x_expected)
or multiple...
tensorcheck([x, y], [xexpected, yexpected])
Not specifying or setting a field to `None` yields a wildcard type; by default, every field is `None`. You can also check that the tensor type is either 'numpy' or 'pytorch'!
tensorcheck(x, Tensor([4, None], library='numpy', device=None))
```
Related work
- We import typeguard (https://github.com/agronholm/typeguard) to extract the mapping between arguments and hints/actual values
- Torchtyping (https://github.com/patrick-kidger/torchtyping) has more features and for now is probably more stable. However it doesn't have very nice outputs since it relies on tensorguard to do all the runtime type checking.
TODOs:
- use a different color for each individual error found in the runtime type checking
Owner
- Name: Logan Engstrom
- Login: lengstrom
- Kind: user
- Location: Cambridge, MA
- Company: MIT
- Website: http://loganengstrom.com/
- Twitter: logan_engstrom
- Repositories: 77
- Profile: https://github.com/lengstrom
CS PhD student at @MIT
Citation (CITATION.cff)
# YAML 1.2
---
authors:
-
family-names: Engstrom
given-names: Logan
cff-version: "1.1.0"
date-released: 2016-10-31
message: "If you use this software, please cite it using these metadata."
repository-code: "https://github.com/lengstrom/tensorguard"
title: "Tensorguard"
version: "1.0"
...
GitHub Events
Total
Last Year
Issues and Pull Requests
Last synced: 11 months ago
All Time
- Total issues: 0
- Total pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Total issue authors: 0
- Total pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
Pull Request Authors
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- termcolor *
- typeguard *