Skip to main content

GradOpTorch

Classical gradient based optimization in PyTorch.

What is GradOpTorch?

GradOpTorch is a suite of classical gradient-based optimization tools for PyTorch. The toolkit includes conjugate gradients, BFGS, and some methods for line-search.

Why not torch.optim?

Not every problem is high-dimensional, highly nonconvex, with noisy gradients.
For such problems, classical optimization techniques can be more efficient.

Installation

GradOpTorch can be installed from PyPI:

pip install gradoptorch

Usage

There are two primary interfaces for making use of the library.

  1. The standard PyTorch object oriented interface:
from gradoptorch import optimize_module
from torch import nn

class MyModel(nn.Module):
    ...

model = MyModule()

def loss_fn(model):
    ...

hist = optimize_module(model, loss_fn, opt_method="bfgs", ls_method="back_tracking")
  1. The functional interface:
from gradoptorch import optimizer

def f(x):
    ...

x_guess = ...

x_opt, hist = optimizer(f, x_guess, opt_method="conj_grad_pr", ls_method="quad_search")

Newton's method is only available in the functional interface

Included optimizers:

'grad_exact' : exact gradient optimization
'conj_grad_fr' : conjugate gradient descent using Fletcher-Reeves search direction
'conj_grad_pr' : conjugate gradient descent using Polak-Ribiere search direction
'newton_exact' : exact newton optimization
'bfgs' : approximate newton optimization using bfgs

Included line-search methods:

'back_tracking' : backing tracking based line-search
'quad_search' : quadratic line-search
'constant' : no line search, constant step size used

Metadata

Release files for gradoptorch 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gradoptorch 0.1.1
File Size Uploaded Provenance
gradoptorch-0.1.1.tar.gz 7.7 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for gradoptorch 0.1.1
File Interpreter ABI Platform
gradoptorch-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 16.7 kB

Release files / gradoptorch-0.1.1.tar.gz

Download URL gradoptorch-0.1.1.tar.gz
Size 7.7 kB
Tags Source
SHA-256 checksum
How to use checksums
418f729cd031bc0b399412deaf147d1f34cdf9f48a3d3081e8569b70e84a2e12
BLAKE2b-256 checksum
How to use checksums
7970ac47995e737894f41dd08a9e38509de59dcea7b27d137ea994968aa3ce71
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.10.10 Darwin/23.0.0

Release files / gradoptorch-0.1.1-py3-none-any.whl

Download URL gradoptorch-0.1.1-py3-none-any.whl
Size 8.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
50b8e32d05d3279e150208f297dbcdd7bb4e21b72eef47ae3970aeb89df098a3
BLAKE2b-256 checksum
How to use checksums
7671879f18f38260dd134d6a7d237900e4356d2e97492819bcdc151b58dc1383
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.10.10 Darwin/23.0.0

Security for gradoptorch 0.1.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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page