Metadata-Version: 2.1
Name: torchmasked
Version: 0.1.0
Summary: Tensor operations with mask for PyTorch.
Home-page: https://github.com/Renovamen/torchmasked
Author: Xiaohan Zou
Author-email: renovamenzxh@gmail.com
License: MIT
Platform: UNKNOWN
Classifier: Intended Audience :: Science/Research
Classifier: Development Status :: 3 - Alpha
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.6
Description-Content-Type: text/markdown
Provides-Extra: dev
License-File: LICENSE

# torchmasked

Tensor operations with mask for PyTorch.

Sometimes you need to perform operations on tensors with the masked elements been ignored, for example:

```python
>>> 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.


&nbsp;

## Installation

From source:

```bash
pip install git+https://github.com/Renovamen/torchmasked.git --upgrade

# or

python setup.py install
```


&nbsp;

## Supported Operations

- max (masked version of `torch.max`)
- min (`torch.min`)
- sum (`torch.sum`)
- mean (`torch.mean`)
- softmax (`torch.nn.functional.softmax` and `torch.nn.Softmax`)


&nbsp;

## License

[MIT](LICENSE)


