Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

torchpwl-0.1.2.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

torchpwl-0.1.2-py2-none-any.whl (7.8 kB view details)

Uploaded Python 2

File details

Details for the file torchpwl-0.1.2.tar.gz.

File metadata

  • Download URL: torchpwl-0.1.2.tar.gz
  • Upload date:
  • Size: 6.9 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

Hashes for torchpwl-0.1.2.tar.gz
Algorithm Hash digest
SHA256 46ba43df266bd6df2e4d2b255e1b7ba9e1e4a91bb766916e0c00cc2140288512
MD5 625132af964e143a50ec49dcc4bdde9b
BLAKE2b-256 ca414ce4308a231ff2222e5718fbdc494bc7ded2fd2f20066f1b126bea4132cd

See more details on using hashes here.

File details

Details for the file torchpwl-0.1.2-py2-none-any.whl.

File metadata

  • Download URL: torchpwl-0.1.2-py2-none-any.whl
  • Upload date:
  • Size: 7.8 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

Hashes for torchpwl-0.1.2-py2-none-any.whl
Algorithm Hash digest
SHA256 d332e1a289c4bd0c745f5f259b18b88ea751fa3ab592fff27dc5d379088992f6
MD5 533bfb1d15528b8016499a54f0c47a8f
BLAKE2b-256 215c5cd353147a00f4cc28f097b639b018430b24adc5a1aa6be6d65130d4e272

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page