Masked Convolution
A PyTorch implementation of a thin wrapper for masked convolutions.
What are masked convolutions?
Similarly to partial convolutions, masked convolutions mask a part of the kernel, essentially ignoring data at specific locations. For an example, consider
a = [1, 2, 3, 4, 5]
assuming we have a convolution kernel
kernel = [1, 1, 1]
convolving over a would give us
a_conv = [6, 9, 12]
However, if we were to mask the convolution kernel with a mask
mask = [1, 0, 1]
masked convolving over a would return
a_masked_conv = [4, 6, 8]
One use of masked convolutions is emulating skip-grams.
Installation
First, make sure you have PyTorch installed. This was tested on Python 3.8 and PyTorch 1.7.1. Further testing is needed to determine whether it works on a different setup - chances are it does. The recommended way to install this is through PyPi by running:
pip install masked-convolution
Other than that, you can clone this repository, and in its root directory (where setup.py is located) run
pip install .
Benchmarks
Every build, automatic benchmarks are run in order to determine how much overhead the implementation brings. The ordinary convolutions are used as a baseline, while the the performance of masked convolutions is described as a percentage of throughput of their respective baselines.
Keep in mind that these benchmarks are in no way professional, they only serve to give users a general idea. Their results greatly differ, so they should be taken with a grain of salt.
- Masked Convolution 1D: 85.29 % Convolution 1D throughput
- Masked Convolution 2D: 85.64 % Convolution 2D throughput
- Masked Convolution 3D: 97.79 % Convolution 3D throughput
Metadata
Release files for masked-convolution 0.3.1
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 | |
|---|---|---|---|---|
| masked-convolution-0.3.1.tar.gz | 6.4 kB | Without provenance | Details |
Release files / masked-convolution-0.3.1.tar.gz
| Download URL | masked-convolution-0.3.1.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
fa84c37a313faaee4cc1e877a48340b83c1b025785ef742f3aed27800ce8d6ea
|
|
BLAKE2b-256 checksum How to use checksums |
2850ae5b3819c66fb2f40c0818370ae0e5304f9e48db1c6e5f8b1ba9bbe8b1d4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0.post20200714 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.3
|
Security for masked-convolution 0.3.1
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.