torchmasked
Tensor operations with mask for PyTorch.
Sometimes you need to perform operations on tensors with the masked elements been ignored, for example:
>>> input = torch.tensor([1., 2., 3.])
>>> result = torch.sum(input)
>>> print(result)
tensor(6.)
>>> mask = torch.tensor([1, 1, 0]).byte()
>>> masked_result = torchmasked.masked_sum(input, mask)
>>> print(masked_result)
tensor(3.) # element input[2] is masked and ignored
Then this package could be helpful.
Installation
From source:
pip install git+https://github.com/Renovamen/torchmasked.git --upgrade
# or
python setup.py install
Supported Operations
- max (masked version of
torch.max) - min (
torch.min) - sum (
torch.sum) - mean (
torch.mean) - softmax (
torch.nn.functional.softmaxandtorch.nn.Softmax)
License
Metadata
Release files for torchmasked 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| torchmasked-0.1.0.tar.gz | 3.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| torchmasked-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.5 kB
Release files / torchmasked-0.1.0.tar.gz
| Download URL | torchmasked-0.1.0.tar.gz |
|---|---|
| Size | 3.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f7a0b9c6e68698f639a1e465cd31d2e26f5cefb4047b4c2492bd912ea6498d15
|
|
BLAKE2b-256 checksum How to use checksums |
256bf2e276a2c55596ecb6a087db954c736b933f8aba4fc573feabadb14851e2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12
|
Release files / torchmasked-0.1.0-py3-none-any.whl
| Download URL | torchmasked-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f6b80a29b3534cfa19681825b1bd31ea7ed38737f7daa059ee118bb7d6ca1bbc
|
|
BLAKE2b-256 checksum How to use checksums |
629b405c9d93a6c1f915c1b52bd3e06519bf08abb7f8179232b2c2de3b64c522
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12
|