Tensor operations with mask for PyTorch.
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
torchmasked-0.1.0.tar.gz
(3.5 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 torchmasked-0.1.0.tar.gz.
File metadata
- Download URL: torchmasked-0.1.0.tar.gz
- Upload date:
- Size: 3.5 kB
- Tags: Source
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f7a0b9c6e68698f639a1e465cd31d2e26f5cefb4047b4c2492bd912ea6498d15
|
|
| MD5 |
9c9f2c95495dfe4c656027efc1d54790
|
|
| BLAKE2b-256 |
256bf2e276a2c55596ecb6a087db954c736b933f8aba4fc573feabadb14851e2
|
File details
Details for the file torchmasked-0.1.0-py3-none-any.whl.
File metadata
- Download URL: torchmasked-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f6b80a29b3534cfa19681825b1bd31ea7ed38737f7daa059ee118bb7d6ca1bbc
|
|
| MD5 |
920b3ad519a557e09e6e776889c23b88
|
|
| BLAKE2b-256 |
629b405c9d93a6c1f915c1b52bd3e06519bf08abb7f8179232b2c2de3b64c522
|