Implementation of Piecewise Linear Functions (PWL) in PyTorch.
Project description
Piecewise Linear Functions (PWLs) can be used to approximate any 1D function. PWLs are built with a configurable number of line segments - the more segments the more accurate the approximation. This package implements PWLs in PyTorch and as such they can be fit to the data using standard gradient descent. For example:
import torchpwl
# Create a PWL consisting of 3 segments for 5 features - each feature will have its own PWL function. pwl = torchpwl.PWL(num_features=5, num_breakpoints=3) x = torch.Tensor(11, 5).normal_() y = pwl(x)
Monotonicity is also supported via MonoPWL. See the class documentations for more details.
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
Built Distribution
File details
Details for the file torchpwl-0.2.0.tar.gz
.
File metadata
- Download URL: torchpwl-0.2.0.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.62.3 importlib-metadata/4.8.2 keyring/23.5.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ac32f3cfff48e8d6a0b2ff0da8a7cd8daa8ccfd2874536c257c60e185379a2e |
|
MD5 | becdc998b0b863e0a209011be40d0442 |
|
BLAKE2b-256 | 0ce515d1dfad1667c16c39a317a02c5da4800919704bd23dcf9d340e7c374cbf |
File details
Details for the file torchpwl-0.2.0-py2-none-any.whl
.
File metadata
- Download URL: torchpwl-0.2.0-py2-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.7 tqdm/4.62.3 importlib-metadata/4.8.2 keyring/23.5.0 rfc3986/1.5.0 colorama/0.4.4 CPython/3.9.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1de62bc3bdda1e5be5a16fbd1b37f8e47d4481deda102e4861296d0471557692 |
|
MD5 | b6f9911f8a18b93676960217614fb7fa |
|
BLAKE2b-256 | 96715a1ee08ad548b8d782e27ce1cf8225c6f41b3aa7681b03a6d5679bda42cb |