Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

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

Download files

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

Files for torchpwl, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size torchpwl-0.1.0-py2-none-any.whl (6.9 kB) File type Wheel Python version py2 Upload date Hashes View hashes
Filename, size torchpwl-0.1.0.tar.gz (5.7 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page